I have graph where some types of nodes has a property name authentication\username , it was never a problem working with neo4j 3.5 but now after migrate do neo4j 4.4 a cypher query like bellow is not working
match (n:Person) where n.`authentication\username` = 'user' return n
neo4j shows an error
Neo.ClientError.Statement.SyntaxError
Invalid input 's': expected four hexadecimal digits specifying a unicode character
It is possible to create a node with such property using :
CREATE (n:Person $props ) return n
Also it used to work under neo4j 3.5 but after migrate to 4.4, Is this kind of property name not allowed anymore?.
Ok I understand the error message about unicode but it sounds like an issue as neo4j doesn't understand that as a property name
It looks like it is being interpreted as a Unicode escape sequence, which starts with ‘\u’, followed by four hex digits. As such, it expected four hex digits after the ‘u’, not ‘s’.
I was thinking of it , one way to solve this would be when trying to convert Unicode, if the next query char after the "u" is not a number it should not consider it as a unicode and accept the string as is. Assuming that cypher uses Latin-based symbols
What do you think?
Your suggestion makes sense, but it is something Neo4j would have to implement.
Maybe neo4j supports unicode in property name strings in 4.0, so you have this issue now. How about you use a different delimiter character instead of the escape character (backslash), such as a forward slash, colon, or underscore?
Your suggestion makes sense, but it is something Neo4j would have to implement.
Maybe neo4j supports unicode in property name strings in 4.0, so you have this issue now. How about you use a different delimiter character instead of the escape character (backslash), such as a forward slash, colon, or underscore?
Your suggestion makes sense, but it is something Neo4j would have to implement.
Maybe neo4j supports unicode in property name strings in 4.0, so you have this issue now. How about you use a different delimiter character instead of the escape character (backslash), such as a forward slash, colon, or underscore?
Not sure if it will be a workaround @glilienfield , as I said It happened after a migration and there are thousands nodes that are using this kind of name pattern that are created by some other systems , and those systems expected that pattern in return.
Maybe It will be necessary to change all systems logic to deal with a different char I dont see other way.
Any kind of possible workaround may "fix" my specific problem but will not fix neo4j "deficiency" , as it allows unicode but not allows "pure string", it sounds very odd.
I'm affraid of move on with the migration to production, right now
Do you thing it is kind of issue that could be fixed in the future?
You are using it in a property name, not a property's value. Can you use a different property name and map it to this name when sending data to another system?
It is fairly simple to change the property name, either with cypher or apoc.refactor.rename.nodeProperty. The problem I encountered is referencing the current property name. Both cypher and the apoc refactor method complain about the unicode value not being correct. I also tried running the cypher using version 3.5, but it also complained about the unicode character.
I also thought about using the java driver to pull each node, update it, and write it back. Unfortunately, java complained about 'an illegal escape character in a literal string' when I tried to use it as a key in a map.
It would be straight forward to refactor to eliminate the property with a new one with the same values if we could access the property to read and remove it. I tried the dynamic access syntax without success.
@glilienfield if we change/ update the property name in the database, for all nodes I will have to change all the systems that are working with this properties to adapt to a new property name pattern and all those systems are used to work with this pattern (xxxx\yyyy) it works for all cases but for xxxx\uyyyyyy , Is there a way to change the property name in the database and keep it invisible for the systems, I mean the systems could still working with the current name pattern and database handles the transformation of the property name when saving, updating and retrieving data ?
Well, I thought the root problem is that you can no longer read nor write to this property. How do you interface with other systems. Maybe you could make the property name transformation in that layer.
Yeah Thas was the root problem until found that i could do this way:
match (n) where n['authentication\\username'] = 'user' return n
but this is not the common way to deal with node properties in queries and the other way (as i discribed at the beggining) is not possible anymore.
I think that the root problem is that neo4j can't handle strings like that and it could be fixed in the code, but if that is not an option at least it could be described in the documentation
Does n['authentication\\username'] access the property?
anyways, I am not sure it is a defect. Looks like they changed to supporting Unicode in property names and didn’t consider if existing databases had illegal names such as yours.