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

with() doesn't work with update statements? #4428

Closed
Linksku opened this issue Apr 12, 2021 · 1 comment · Fixed by #4508
Closed

with() doesn't work with update statements? #4428

Linksku opened this issue Apr 12, 2021 · 1 comment · Fixed by #4508

Comments

@Linksku
Copy link

Linksku commented Apr 12, 2021

Environment

Knex version: 0.95.2
Database + version: MySQL 8.0.22
OS: WSL Ubuntu 20

Bug

  1. Explain what kind of behaviour you are getting and how you think it should do

When using with() with update(), the with statement doesn't appear in the query.

  1. Error message

None

  1. Reduced test code, for example in https://npm.runkit.com/knex or if it needs real
    database connection to MySQL or PostgreSQL, then single file example which initializes
    needed data and demonstrates the problem.
knex('foo')
  .with('foo2', builder => builder.select('*').from('foo'))
  .update({ col: 1 });

Expected query:

with `foo2` as (select * from `foo`) update `foo` set `col` = 1

Actual query:

update `foo` set `col` = 1

Edit:

It looks like this can be fixed by adding this.with() to QueryCompiler_MySQL.update

@kibertoad
Copy link
Collaborator

Released in 1.0.2

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.

2 participants