Skip to content

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

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

Closed
1 task done
jelder opened this issue Nov 14, 2024 · 3 comments · Fixed by #3555
Closed
1 task done
Labels
bug Something isn't working priority Will be worked on next qb/crud

Comments

@jelder
Copy link
Contributor

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
@L-Mario564 L-Mario564 added priority Will be worked on next qb/crud labels Nov 28, 2024
@suriyadi15
Copy link

UP

@devotoali
Copy link

Hi there, any updates on this?

@Sukairo-02 Sukairo-02 mentioned this issue Apr 23, 2025
@AndriiSherman
Copy link
Member

Fixed in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority Will be worked on next qb/crud
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants