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

[BUG]: for("update", { noWait: true }) yields invalid SQL: syntax error at or near "no" #3554

Open
1 task done
jelder opened this issue Nov 14, 2024 · 0 comments · May be fixed by #3555
Open
1 task done

[BUG]: for("update", { noWait: true }) yields invalid SQL: syntax error at or near "no" #3554

jelder opened this issue Nov 14, 2024 · 0 comments · May be fixed by #3555
Labels
bug Something isn't working

Comments

@jelder
Copy link

jelder commented Nov 14, 2024

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.23.0

What version of drizzle-kit are you using?

0.32.1-848e136

Other packages

No response

Describe the Bug

Given something like this, where tx is a Drizzle transaction.

  tx.select().from(widgets).for("update", { noWait: true }),

The resulting SQL looks like

select * from widgets for update no wait;

That will result in the error syntax error at or near "no" because Postgres spells this option as a single word:

select * from widgets for update nowait;

This is confusing because the other option here is spelled as two words:

select * from widgets for update skip locked;

Fortunately this can be fixed by simply removing this space:

if (lockingClause.config.noWait) {
clauseSql.append(sql` no wait`);

Relevant Postgres documentation:
https://www.postgresql.org/docs/16/sql-select.html#:~:text=The%20locking%20clause%20has,%5B%2C%20...%5D%20%5D%20%5B%20NOWAIT%20%7C%20SKIP%20LOCKED%20%5D

@jelder jelder added the bug Something isn't working label Nov 14, 2024
@jelder jelder linked a pull request Nov 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant