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 must specify unqualified relation names #5053

Open
jacopofranza opened this issue Mar 10, 2022 · 0 comments · May be fixed by #5791
Open

BUG - FOR UPDATE must specify unqualified relation names #5053

jacopofranza opened this issue Mar 10, 2022 · 0 comments · May be fixed by #5791

Comments

@jacopofranza
Copy link

jacopofranza commented Mar 10, 2022

Environment

Knex version: 1.0.3
Database + version: PostgreSQL 13
OS: Node 14

Bug

The error comes up when you build a query like knex('users').withSchema('myschema').where('id','xyz').forUpdate('users')
It seems incompatible to use withSchema and forUpdate in the same query because withSchema add the schema also in front of the forUpdate table name, but should not.

Error message: "FOR UPDATE must specify unqualified relation names"

Ps.: the above query works if I do not specify table name in forUpdate, but in query with joins you must specify the table name otherwise you get "FOR UPDATE cannot be applied to the nullable side of an outer"

ErinCall added a commit to ErinCall/knex that referenced this issue Jan 19, 2024
When the _tableNames helper was written there were multiple methods
hitting it, but they've since been merged into the single _lockingClause
method. Given that the only really interesting thing it was doing was
prepending the schema name--which is the incorrect behavior this commit
fixes--it didn't seem worth keeping at this point.

I'm not sure you'd say `.withSchema('public')` in a real query but it
lets me exercise the behavior in question without having to learn enough
about knex's test environment to stand up a discrete schema. I suppose
it's plausible that a reasonable maintainer would go "hm that's silly
and redundant" and inadvertently remove coverage for this bug, though.
@ErinCall ErinCall linked a pull request Jan 19, 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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant