Neptune with Tinkerpop > How to escape $ symbol?

593 views
Skip to first unread message

Srinath Ganesh

unread,
Aug 9, 2018, 6:17:54 AM8/9/18
to Gremlin-users

Tried to add a property that contains $


gremlin> g.V('some-node-id').property("money", "10 $")
groovysh_parse: 1: illegal string body character after dollar sign;
   solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" @ line 1, column 72.
   ').property("money", "10 $")


So I escaped the $ symbol

gremlin> g.V('some-node-id').property("money", "10\$")
{"requestId":"xyz","code":"MalformedQueryException","detailedMessage":"Query parsing failed at line 1, character position at X, error message : token recognition error at: '$'"}
Type ':help' or ':h' for help.


Try a basic escaping, that worked fine

gremlin> g.V('some-node-id').property("money", "10\"")
==>v[some-node-id]


Double the escape $ since Neptune has gone crazy

gremlin> g.V('some-node-id').property("money", "10\\$")
groovysh_parse: 1: illegal string body character after dollar sign;
   solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}" @ line 1, column 72.
   ').property("money", "10\\$")
                                 ^


Whats wrong in my query?


-----------------------------------------------------------------------------------------------------------
SO: https://stackoverflow.com/q/51744994/1897935

Robert Dale

unread,
Aug 9, 2018, 9:51:46 AM8/9/18
to gremli...@googlegroups.com
It might be Neptune. I believe the second error message is from Neptune and not Gremlin Server.  Perhaps $ is not an allowed character.

This works with stock Gremlin Server:
client.submit("g.addV().property('test','\$1')")

These also work with both remote console and remote graph:
g.addV().property('test','$1')
g.addV().property('test',"\$1")

Robert Dale


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/f3d9d28c-3914-480b-9ccc-52c997206561%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Mallette

unread,
Aug 9, 2018, 9:56:13 AM8/9/18
to Gremlin-users
I said something similar here:


Neptune has a bug in it's parser would be my guess.

Divij Vaidya

unread,
Aug 10, 2018, 6:34:14 PM8/10/18
to Gremlin-users
Hi

Thanks for reporting this issue. This has also been answered in the Amazon Neptune forums https://forums.aws.amazon.com/thread.jspa?messageID=862849

The workaround for this problem is to use single quotes around the string where you are adding the $ sign. For example:

gremlin> g.addV("Animal").property(id,"simba")
==>v[simba]
gremlin
> g.V('simba').property('money','$123')
==>v[simba]
gremlin
> g.V().has('money','$123')
==>v[simba]
gremlin
> g.V('simba').property('new_money','123 $10')
==>v[simba]

However, I do understand that it should work with the double quotes as well after you escape the $. This is a bug in our parser and we are actively working on a fix.

Further I should note that the bug only impacts the clients written in groovy language which send queries as strings e.g. gremlin console. GLVs (Java/Python/DotNet/JS) and other string-based clients where the '$' character is not a reserved character will work just fine.

Regards,
Divij
Reply all
Reply to author
Forward
0 new messages