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

[MySQL] Pdb incorrectly escapes queries with backslash #96

Open
tnovo opened this issue Dec 28, 2018 · 4 comments
Open

[MySQL] Pdb incorrectly escapes queries with backslash #96

tnovo opened this issue Dec 28, 2018 · 4 comments

Comments

@tnovo
Copy link

tnovo commented Dec 28, 2018

When performing a query to the database (using mysql backend):

Query q = select(all())
                .from(table("table"))
                .where(eq("id", k("my\id"));

engine.query(q);

pdb incorrectly escapes the query to

SELECT * FROM `table` WHERE `id` = 'my\id' ;

where it should be (notice the double \ )

SELECT * FROM `table` WHERE `id` = 'my\\id' ;

this is independent of the data in the table itself.

This behaviour does not appear in prepared statements because the escaping is delegated to the driver

@jmf-tls
Copy link
Member

jmf-tls commented Jul 3, 2019

Just to add some context: this is not a problem with PostgreSQL

@maiph
Copy link

maiph commented Jul 6, 2019

I would say that is working as intended. \ in java in an escape character and it will interpret the next character in a different way ("\i" is not event valid syntax). If you want to have a literal \ in your statement you need to escape the \ on your string. Ex: "my\\id"

@tnovo
Copy link
Author

tnovo commented Jul 6, 2019

It should work in the same way for other database engines, meaning that the same query should work regardless of the engine.

@maiph
Copy link

maiph commented Jul 6, 2019

"my\id" won't work anywhere because it won't even compile

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

No branches or pull requests

3 participants