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

DELETE command with alias is invalid SQL syntax for MySQL #77

Open
CYBAI opened this issue Mar 11, 2020 · 0 comments
Open

DELETE command with alias is invalid SQL syntax for MySQL #77

CYBAI opened this issue Mar 11, 2020 · 0 comments

Comments

@CYBAI
Copy link

CYBAI commented Mar 11, 2020

First of all, thanks for building this awesome library for generating type safe SQL queries.

While using this lib to build some queries, I found this issue for DELETE command.

, eqProp "delete-scalar" deleteScalarX
"DELETE FROM TEST.set_a T0 \
\ WHERE (T0.int_a0 = (SELECT ALL T1.int_b0 AS f0 \
\ FROM TEST.set_b T1 \
\ WHERE (T1.int_b0 = 0)))"

Like the raw SQL command written in test of relational-query, currently, HRR will generate delete command with alias which is invalid syntax for MySQL.

Ex.

DELETE FROM table T0 WHERE T0.field = 'value';

There might be two solutions to fix this:

  1. Don't use alias for DELETE

DELETE FROM table WHERE field = 'value';

  1. Declare alias after DELETE would be valid syntax

(Edited: it's very sad this one will be invalid syntax for PostgreSQL 😢 )

DELETE T0 FROM table AS T0 WHERE T0.field = 'value';

As the second one is invalid for PostgreSQL, maybe we will need to fix this by the first solution 🤔 ?

@khibino WDYT? Thank you!

@CYBAI CYBAI changed the title DELETE command with alias is invalid SQL syntax DELETE command with alias is invalid SQL syntax for MySQL Mar 11, 2020
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

1 participant