Open 0xPaul opened 3 years ago
WITH
seems to be a special case of a sub-query from the building/syntax standpoint. Linking https://github.com/doctrine/dbal/issues/2305 for reference.
SQL Server also supports CTEs: https://learn.microsoft.com/en-us/sql/t-sql/queries/with-common-table-expression-transact-sql?view=sql-server-ver16
I'd love to see this included. I have a lot DB views and TVFs that use CTEs and it would be a lot simpler to maintain these as queries in my repository classes. 👍
Someone has to build this feature so we can include it. Do you want to give it a try?
I’d love to but I have a lot of work at present. Hopefully December will be quieter and I can have a look then.
Has there been any traction on bringing CTEs into query builder ?
No. Do you want to work on the feature?
An wrapper library for DBAL level native SQL: https://github.com/somnambulist-tech/cte-builder
Thanks @n0099, that looks like an interesting project. Sadly for me that would mean a rewrite of all my queries as it doesn't look like it supports DQL.
This is the DBAL repository. DQL is out of scope here anyway. The ORM has its own query builder for DQL.
I made a PR for this. Could I have a review on implementation before adding doc and tests ?
@nio-dtp, thank you for the PR. Reviewing the code w/o being able to run it (by means of unit and integration tests) is challenging. Please add the tests.
Feature Request
Summary
References