Show datatype in neo4j browser?

Is there a way to show the datatypes in the neo4j browser?

If a property has a number, you can't see if it is a string or a number. Same with boolean, it just shows "PropertyName: true", and you have no idea if it is a boolean true or a string "true"

Something like "PropertyName [bool]: true" or "PropertyName [number]: 123" would be helpful.

Since Neo4j is a schema free database this could be challenging for a given property could actually have different datatypes for multiple nodes. For example creating 3 nodes as follows

neo4j> create (n:MPasadu {id:1});
0 rows available after 413 ms, consumed after another 0 ms
Added 1 nodes, Set 1 properties, Added 1 labels
neo4j> create (n:MPasadu {id:'true'});
0 rows available after 23 ms, consumed after another 0 ms
Added 1 nodes, Set 1 properties, Added 1 labels
neo4j> create (n:MPasadu {id:true});
0 rows available after 26 ms, consumed after another 0 ms
Added 1 nodes, Set 1 properties, Added 1 labels

and running the following will return the datatypes, but note the id property has multiple datatypes


neo4j> match (n:MPasadu) return n.id,apoc.meta.type(n.id);
+-------------------------------+
| n.id   | apoc.meta.type(n.id) |
+-------------------------------+
| 1      | "INTEGER"            |
| "true" | "STRING"             |
| TRUE   | "BOOLEAN"            |
+-------------------------------

Admittedly I might expect in most cases that a given property on a node is generally all the same datatype, i.e. if you had a property named age, 99% of those properties would be a INTEGER datatype. Is there a benefit to having the datatype? for example without the awareness/detail of the datatype does this cause further downstream effect?

2 Likes

Hey,
thanks for the answer. I did not consider that it's possible to have a node with the same property but different types. Is that a typical use case?

I don't think there are downstream effects. Only it's inconvenient not being sure as to what a "read"-cypher has to look like. Also it could prevent further errors by developers writing cyphers expecting a specific type and then only getting a subset of nodes back because the datatype was different (e.g. 1 and "1").

It strikes me as a rather odd design choice reminding me of early PHP or JavaScript, just being able to put anything into a property. Maybe it's worth the discussion that a property with the same name on the same (labeled) node needs to have the same type as well? Maybe it doesn't matter?