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

Strings with trailing backslashes generate invalid SQL #366

Open
stickystyle opened this issue Jan 8, 2020 · 2 comments · May be fixed by #689
Open

Strings with trailing backslashes generate invalid SQL #366

stickystyle opened this issue Jan 8, 2020 · 2 comments · May be fixed by #689

Comments

@stickystyle
Copy link
Contributor

(Might be related to #238)

If you have a string value that ends in an escaped backslash, the query generated will be invalid because it will escape the quoted string in the query.

>>> import pypika
>>> 
>>> table = pypika.Table("a_table")
>>> query = pypika.MySQLQuery.update(table).set(table.column_1, "value_1\\")
>>> print(str(query))
UPDATE `a_table` SET `column_1`='value_1\'
@Cruuncher
Copy link

This one is a real gotcha that wouldn't pop up in testing either, and bite you in production

@p-baleine
Copy link

I think that Parametrized Queries are utilizable for in such cases.

https://pypika.readthedocs.io/en/latest/2_tutorial.html#parametrized-queries

pierresouchay pushed a commit to pierresouchay/pypika that referenced this issue Jul 5, 2022
@pierresouchay pierresouchay linked a pull request Jul 5, 2022 that will close this issue
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 a pull request may close this issue.

3 participants