Repository navigation
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? |
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. |
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? |
|
@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. |
|
@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. |
|
oups it got automatically closed |
| } | ||
| if ( | ||
| !this.connection.driver.cteCapabilities.writable && | ||
| !(cte.queryBuilder instanceof SelectQueryBuilder) |
There was a problem hiding this comment.
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.
|
looks good 👍 |
|
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
masterbranchnpm run lintpasses with this changenpm run testpasses with this changeFixes #0000