-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
materialized CTE support for Postgres #4948
Conversation
#4948 related |
Why it's not visible? Should I build something special for integration test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I will push integration2 + doc tests on my PR today (add integration tests).
@@ -124,6 +124,20 @@ class Builder extends EventEmitter { | |||
return this.withWrapped(alias, statementOrColumnList, nothingOrStatement); | |||
} | |||
|
|||
withMaterialized(alias, statementOrColumnList, nothingOrStatement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You implement the functionnality for all database, but only available PG and Sqlite3, so no need here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you imply this should be added to PG dialect only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should throw an error on dialects which do not support it. so base method should throw, pg and sqlite should override it to actually do something useful
@@ -1160,6 +1160,16 @@ class QueryCompiler { | |||
this.client, | |||
this.bindingsHolder | |||
); | |||
|
|||
let sqlMaterialized = ''; | |||
const canMaterialized = this.client.config.client === 'pg'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont do check like this in generic files.
Fixed by 6398098 |
knex.withMaterialized('t',knex('users')).from('t')
forwith 't' as materialized (select * from users) select * from t
and
knex.withNotMaterialized('t',knex('users')).from('t')
->with 't' as not materialized (select * from users) select * from t
https://www.postgresql.org/docs/current/queries-with.html#id-1.5.6.12.7
I will add documentation changes if this is approved