cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

Neo4j cypher error when node property name contains \u for example: authentication\username

Henrique
Node Link

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

17 REPLIES 17

glilienfield
Ninja
Ninja

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’. 

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!

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

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? 

Thanks

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? 

Henrique
Node Link

Thats is a workaround that I could try, Do you know how could I do that @glilienfield ? 

 

bennu_neo
Neo4j
Neo4j

Hi @Henrique ,

Kinda interesting! How does one user node looks? Can you share one screenshot? I guess the property looks like : "authentication\\username"

Oh, y’all wanted a twist, ey?

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
it works
 
but If I query using:
match (n) where n.`authentication\username`  = 'user'  return n
it doesnt work (unicode error)
 
if I try 
match (n) where n.`authentication\\username`  = 'user'   return n
it doesn't match nodes
 
Unicode is trying to make me crazy

glilienfield
Ninja
Ninja

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.

 

.

Henrique
Node Link

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 🙂

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

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?

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. 

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