Files
Stefan Bürk 3ccea71a7b Make it possible to create union main part for a CTE (#7326)
<!-- Fill in the relevant information below to help triage your pull
request. -->

|      Q       |   A
|------------- | -----------
| Type         | bug
| Fixed issues | #7318

#### Summary

<!-- Provide a summary of your change. -->

Technically this change adopts the solution for adding 
the CTE with parts to a SELECT query for UNION query
handling using the `WithSQLBuilder` in case with parts
has been set to allow creating queries like

```sql
WITH
-- CTE with parts
  cte_a AS (SELECT * FROM a_table)

-- CTEmain part
      (SELECT cte_a.*, 'lit1' from cte_a)
UNION (SELECT cte_a.*, 'lit2' from cte_a)
```

using the `union` and `with` api on the same level:

```php
$qb = $connection->createQueryBuilder();

$cte = $qb->sub()
  ->select('*')
  ->from('a_table');

$union1 = $qb->sub()
  ->select('cte_a.*', $qb->expr()->literal('lit1'))
  ->from('cte_a');

$union1 = $qb->sub()
  ->select('cte_a.*', $qb->expr()->literal('lit2'))
  ->from('cte_a');

$qb->with('cte_a', $cte)
  ->union($union1)
  ->addUnion($union2);
```

This is a valid use-case and supported by databases supporting
common table expressions albeit I could not find that documented
in any documentation and real world use-cases exists and is the
reason why this change has been considered as bugfix.
2026-03-03 13:12:17 +01:00
..
2025-10-30 08:45:53 +01:00
2025-10-30 08:45:53 +01:00
2018-01-01 12:50:50 -02:00