Thanks to visit codestin.com
Credit goes to github.com

Skip to content

position of with/CTE (top-level or together with subquery) #3779

@ameinhardt

Description

@ameinhardt

Environment

Knex version: 0.20.10
Database + version: MySQL 8.0
OS: Windows OS: Windows / linux docker dbs

Feature discussion / request

I would like to update tree nodes recursively in mysql with CTE in whereExists( select ...). Although I could put with into the whereExists's select in mysql and sqlite, that breaks mssql where with has to be at root level.
In mysql's compiler, some methods don't seem to include with(). Is there a reason for that or can with() be included?
Currently, I would overwrite it with

const mySqlUpdate = MySqlQueryCompiler.prototype.update;
MySqlQueryCompiler.prototype.update = function() {
  return this.with() + mySqlUpdate.apply(this, arguments);
};```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions