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
feat: support for Common Table Expressions #8534
Conversation
Why does it marked for 0.3.0? If there are no breaking changes we can introduce it in 0.2.x. |
I marked it as 0.3.0 because original issue #1116 was marked as 0.3.0. I can't see any breaking changes. |
ah okay, then we can unmark it and release in 0.2.x. Also we probably need to specify in the documentation what databases support this feature. And do you have in plans add other databases support? |
5790039
to
678cae5
Compare
Common table expressions are supported in all major databases... But MySQL supports them since 8.0, but TypeORM tests against MySQL 5.7. MySQL 5.7 goes EOL in 2023. DML in CTE is supported only in Postgres I think, I updated docs. |
678cae5
to
9045252
Compare
we can:
|
@pleerock Overall, I think it's reasonable to provide some kind of version check into |
yes, would be good to have. |
I will try to have a look at this. Maybe it makes sense to do simple connection.query(`WITH cte_test AS (SELECT 1 AS bar) SELECT * FROM cte_test`); instead of hard-coding checks. Or disable support for CTEs by default for certain (only MySQL?) database drivers and specify @pleerock Which approach should I choose? @AlexMesser Linked check made me think that TypeORM should explicitly say which database versions it supports. I think support for EOL databases should be explicitly dropped. |
@Ginden why can't we go with version checks as @AlexMesser suggested? |
9045252
to
b5a962d
Compare
@pleerock Done! |
Tests are failing... |
Hm, these tests fail only if MySQL 8.0 is enabled in tests. I added After disabling I will have a look at this, whether it's issue with TypeORM or EDIT:
|
Full list of issues with enabling MySQL 8.0 in tests:
Also:
I created #8713 to track these. |
I'm not sure why Postgres 12 test fails with:
Oracle needs fixing though. |
e3fbd6f
to
58a2570
Compare
@pleerock I need assistance with this one - tests pass for Tests pass locally on my machine connected to Docker, so I suppose it's something related to CircleCI specific configuration. |
56dc995
to
2f5475c
Compare
oups it got automatically closed |
src/query-builder/QueryBuilder.ts
Outdated
} | ||
if ( | ||
!this.connection.driver.cteCapabilities.writable && | ||
!(cte.queryBuilder instanceof SelectQueryBuilder) |
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.
replace it with InstanceChecker.isSelectQueryBuilder
. From 0.3.0 we avoid using instanceof
because it doesn't play well in the monorepo projects with multiple instances of TypeORM across different node_modules.
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.
Done.
looks good 👍 |
2f5475c
to
93e9e71
Compare
93e9e71
to
89870af
Compare
thank you a lot |
Resolves #1116 #5149 #5484
Description of change
This pull request adds support for common table expressions in QueryBuilder.
Pull-Request Checklist
master
branchnpm run lint
passes with this changenpm run test
passes with this changeFixes #0000