planetscale/database-js

Syntax error at position 42 near 'WHERE'

steven-tey opened this issue · 1 comments

Hey! Great job on this JS driver! :)

I tried to run a simple query:

SELECT * FROM database.table LIMIT 100 WHERE slug = 'xyz'

But I got the following error:

syntax error at position 42 near 'WHERE'

I later realized that it's because my LIMIT clause cannot come before my WHERE clause.

i.e. this works:

SELECT * FROM database.table WHERE slug = 'xyz' LIMIT 100

Would be nice if we can write a freeform SQL query without restricting the clause sequence :)

Hey @steven-tey! This is a requirement by the SQL syntax. Have you been able to do this with an ORM I'm guessing?

With this library we're passing the SQL through as-is to the database. We don't plan on building an ORM, but it's certainly possible our data API (or this library) could be used as the backend for an existing or new one.