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

updateFrom is not substituted into update #5640

Open
givename opened this issue Jul 24, 2023 · 0 comments
Open

updateFrom is not substituted into update #5640

givename opened this issue Jul 24, 2023 · 0 comments

Comments

@givename
Copy link

Environment

Knex version: 2.5.1
Database + version: postgres + 15.3
OS: windows 10

updateFrom is not substituted into update

query:

knex
  .with("next_task", (qb) => {
    qb.select("id")
      .from("qc_task")
      .where({
        status: 0,
        type,
      })
      .limit(1)
      .forUpdate()
      .skipLocked();
  })
  .updateFrom("next_task")
  .update({
    status: 1,
    attempt: knex.raw("attempt + 1"),
    begin_time: knex.fn.now(),
    updated: knex.fn.now(),
  })
  .from("qc_task")
  .where(knex.raw("qc_task.id = next_task.id"))
  .returning(["qc_task.id", "qc_task.json"])

sql:

  with "next_task" as (select "id" from "qc_task" where "status" = ? and "type" = ? limit ? for update skip locked) 
  update "qc_task" -- expected to be substituted from the "fromUpdate"
  set "status" = ?, "attempt" = attempt + 1, "begin_time" = CURRENT_TIMESTAMP, "updated" = CURRENT_TIMESTAMP 
  from "next_task" -- expected to be substituted from the "from"
  where qc_task.id = next_task.id 
  returning "qc_task"."id", "qc_task"."json

I'm not sure if this is a bug, maybe it should be, but it turned out not to be very obvious

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

No branches or pull requests

1 participant