tile38
tile38 copied to clipboard
syntax error when using whereeval
I'm the author of the node-tile38 library that is used to interface node.js applications with Tile38. I'm looking into a bug that was reported a while ago but I'm a bit stumped on the root cause. If a user sends a nearby query using whereeval with value 'return FIELDS.areaId ~= ARGV[1]' , a syntax error is returned.
I'm fairly certain that the syntax error is returned by Tile38 server but have not been able to determine what's wrong with the query and/or if a fix/workaround is possible within node-tile38. Based on what I can find in the docs, this query should be accepted. For more context, please see:
https://github.com/phulst/node-tile38/issues/28
Would appreciate your help with this
I have run into issues (in Tile38 & Redis) with Lua scripts throwing errors when mixing strings with numbers in relational operators. Not sure if this is what is occurring here.
I tested on my side and I'm seeing the same issue.
The cause appears to be that the node-tile38 client is wrapping the WHEREEVAL script in extra double-quote characters prior to sending the command to the tile38 server.
The server then sends the command with extra quotes to the lua engine, which raises an error.
I got it to work when I remove the wrapped quotes.
https://github.com/phulst/node-tile38/blob/master/src/tile38_query.js#L97
I changed
let arr = ['WHEREEVAL', `"${script}"`, args.length].concat(args);
to
let arr = ['WHEREEVAL', script, args.length].concat(args);
Thanks, I am fixing this in the node library then.