Skip to content
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

Escape literals #408

Merged
merged 3 commits into from
Sep 19, 2024
Merged

Escape literals #408

merged 3 commits into from
Sep 19, 2024

Conversation

angrykoala
Copy link
Member

Escape literal strings if they contain invalid characters:

new Cypher.Literal(`Hello "World"`);

Would get translated into the following Cypher:

"Hello \"World\""

Copy link

changeset-bot bot commented Sep 17, 2024

🦋 Changeset detected

Latest commit: 33a913d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@neo4j/cypher-builder Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

expect(escapeLiteralString("")).toBe("");
});

test.each([[`my "var"`, `my \\"var\\"`, `my \\"var`, `my \\\\"var`]])("Escape '%s'", (original, expected) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is a typo here: there is only one element in the list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@angrykoala angrykoala merged commit 737e436 into 2.x Sep 19, 2024
@angrykoala angrykoala deleted the 241-escape-literals branch September 19, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants