Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-09-2022 09:47 AM
Hi All,
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
What are your thoughts about it guys?
Thanks
Henrique
06-09-2022 12:02 PM
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’.
06-09-2022 01:15 PM
Yes right! The point here is that neo4j is restricting the property name so I cannot use name like "clothing\uniform" or like below
where n.`authentication\username`
Why we are facing this restriction in neo4j 4.4?
Thanks!
06-10-2022 01:33 PM
Hi @glilienfield ,
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?
Thanks
06-11-2022 05:21 AM
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?
06-13-2022 09:15 AM
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?
Thanks
06-13-2022 09:25 AM
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?
06-13-2022 10:17 AM - edited 06-13-2022 10:19 AM
Thats is a workaround that I could try, Do you know how could I do that @glilienfield ?
06-13-2022 10:31 AM
Hi @Henrique ,
Kinda interesting! How does one user node looks? Can you share one screenshot? I guess the property looks like : "authentication\\username"
06-14-2022 03:15 PM
Hi @bennu_neo ,
I still dont know how the property looks like
if I query nodes using
match (n) where n['authentication\\username'] = 'user' return n
match (n) where n.`authentication\username` = 'user' return n
match (n) where n.`authentication\\username` = 'user' return n
06-14-2022 09:41 AM
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.
.
06-14-2022 03:03 PM
Hi Guys,
I tryed to query the nodes using:
match (n) where n['authentication\\username'] = 'user' return n
it worked .
I'm using java driver as well , I can update, create
update :
Match (n) Where id(n)= $id SET n = $props return n
Create:
CREATE (n:Person $props ) return n
This unicode is been a headache for me 🙂
06-14-2022 08:11 PM
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.
06-15-2022 04:41 AM - edited 06-15-2022 04:43 AM
@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 ?
06-16-2022 09:51 AM
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.
06-16-2022 06:15 PM
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
https://neo4j.com/docs/cypher-manual/current/syntax/naming/
"Don't create property names containing "\u" like "authentication\username" but for unicode only"
if it is created with "U" its okay "authentication\Username"
What do you think about creating an issue in github to fix it?
06-16-2022 07:01 PM
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.
You can give it a try.
06-16-2022 07:30 PM - edited 06-16-2022 07:32 PM
Yes , it access. but n.`authentication\username` doesnt
I'm trying to find where it says it is an illegal name, I havent find it anywhere in the docs
All the sessions of the conference are now available online