age icon indicating copy to clipboard operation
age copied to clipboard

SQL Command throws Error in cypher.sql

Open skkk98 opened this issue 3 years ago • 5 comments

I came across some commands that throw errors in cypher.sql and I am not sure whether this is expected behavior or not.

I am unsure whether this is okay because the expected and actual results throw log these errors when running this command.

SELECT * FROM cypher('cypher', 'RETURN 0') AS r(c text); ERROR: a dollar-quoted string constant is expected LINE 1: SELECT * FROM cypher('cypher', 'RETURN 0') AS r(c text);

SELECT * FROM cypher('cypher', NULL) AS r(c text); ERROR: a dollar-quoted string constant is expected LINE 1: SELECT * FROM cypher('cypher', NULL) AS r(c text);

Are these test cases valid? Or should it be changed? like SELECT * FROM cypher('cypher', $$RETURN 0$$) AS r(c text);

Also if these test cases are valid then is okay to add a test case like SELECT * FROM cypher('cypher', ##RETURN 0##) AS r(c text); since this will throw an error as well.

skkk98 avatar Oct 10 '22 19:10 skkk98

Yes those regression tests are confirming that the second argument of the Cypher function cannot be NULL and cannot be a single-quoted string.

JoshInnis avatar Oct 11 '22 01:10 JoshInnis

If this has been resolved, please make sure to close the issue :)

jrgemignani avatar Oct 17 '22 17:10 jrgemignani

Sorry, I should have noted the following before suggesting closing the issue -

If those regression tests are supposed to throw errors and there isn't a comment stating that, I think that a comment should be added for clarity.

jrgemignani avatar Oct 18 '22 16:10 jrgemignani

The following comments are written before those tests, so I think no additional comments will be necessary.

-- cypher() function takes only a dollar-quoted string constant as an argument.
-- All other cases throw an error.

https://github.com/apache/age/blob/master/regress/sql/cypher.sql#L25-L26

shinyaaa avatar Aug 09 '24 10:08 shinyaaa

@shinyaaa This isn't necessarily true anymore. The function can be called, in special cases, cypher(null, null).

jrgemignani avatar Aug 09 '24 19:08 jrgemignani