-
Notifications
You must be signed in to change notification settings - Fork 44
Changes utilities.py:to_cypher_value to utilize double quotes when …
#341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…creating cypher values and updates test coverage.
antejavor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good, since it improves consistent in string quotes
|
Hi @james-geiger, I see there are other tests that should be fixed accordingly. Also, let me see if I understood correctly: The problem you're resolving here is the case of having a single apostrophe in a string. A current approach in GQLAlchemy uses a single apostrophe around the string in the Cypher query. That is not a good approach when a string has a single apostrophe. A solution to this issue is to have double quotes around a string in Cypher that allows a single apostrophe when needed. This PR doesn't include any changes related to the |
|
@katarinasupe Changes in a727fbb to utilize In the current release, gqlalchemy utilizes a f-string with single quotes to wrap string property values being generated as part of a cypher query. Because python allows for string instantiation with either single or double quotes, developers who utilize double quotes to instantiate a string containing a single quote, e.g.: Node(property="This is the node's best friend.")will encounter a cypher Invalid Query error because the generated cypher command would result in a broken property value, e.g.: MERGE (n:Node {property:'This is the node's best friend.'}Similar issues are encountered in the OGM when newlines are utilized alongside single and double-quotes. The cases = [
('C1', 'This text is very plain and dry.'),
('C2', 'This text has a\nsemantic newline.'),
('C3', "This text both a possessive's and a\nsemantic newline."),
('C4', 'This text has "quotes" around something specific.'),
('C5', 'This text has an escaped possessive\'s, a\nsemantic newline, and a "quote" from the author.')
]
for title, text in cases:
print(text.isprintable(),'|', repr(text) if text.isprintable() else rf"'{text}'")
|
|
Hi @james-geiger, thank you for this contribution! Can you just make sure you run all tests and fix them so they work well with your fix? You can see where they're failing in our checks. |
|
@katarinasupe Do I need to have an active Neo4j instance for all the tests to run? I think I'm missing some because I only currently have Memgraph set up. |
|
No worries about Neo4j tests, you can ignore those @james-geiger (I think they will pass here). |
|
@katarinasupe All tests passing on my local runner for python 3.11. |
|
@james-geiger it seems that all tests are passing now! Thank you again for your contribution! 🙏 |
|
Hi @james-geiger, can you remove Enum commit from this PR? |
This reverts commit d84f83c.
@katarinasupe Reverted, sorry! |
…creating cypher values.
Description
This PR alters the
to_cypher_valuesfunction to utilize double quotes when serializing into a cypher query.Pull request type
Please delete options that are not relevant.
Related issues
Delete section if this PR doesn't resolve any issues.
Closes:
#318
#249
Checklist:
######################################
Reviewer checklist (the reviewer checks this part)
######################################