vapor / sql-kit

*️⃣ Build SQL queries in Swift. Extensible, protocol-based design that supports DQL, DML, and DDL.
MIT License
248 stars 58 forks source link

Add support for Common Table Expressions #179

Closed gwynne closed 5 months ago

gwynne commented 6 months ago

These changes are now available in 3.31.0

CTEs (WITH clauses) are now supported by SELECT, INSERT, UPDATE, DELETE, and UNION queries, including subqueries. Test and docs coverage is 100%.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (25d8170) to head (db4789b).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #179 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 98 100 +2 Lines 2565 2635 +70 ========================================= + Hits 2565 2635 +70 ``` | [Files](https://app.codecov.io/gh/vapor/sql-kit/pull/179?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [...it/Builders/Implementations/SQLDeleteBuilder.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FBuilders%2FImplementations%2FSQLDeleteBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvSW1wbGVtZW50YXRpb25zL1NRTERlbGV0ZUJ1aWxkZXIuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...it/Builders/Implementations/SQLInsertBuilder.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FBuilders%2FImplementations%2FSQLInsertBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvSW1wbGVtZW50YXRpb25zL1NRTEluc2VydEJ1aWxkZXIuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...Kit/Builders/Implementations/SQLUnionBuilder.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FBuilders%2FImplementations%2FSQLUnionBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvSW1wbGVtZW50YXRpb25zL1NRTFVuaW9uQnVpbGRlci5zd2lmdA==) | `100.00% <100.00%> (ø)` | | | [...it/Builders/Implementations/SQLUpdateBuilder.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FBuilders%2FImplementations%2FSQLUpdateBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvSW1wbGVtZW50YXRpb25zL1NRTFVwZGF0ZUJ1aWxkZXIuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...s/Prototypes/SQLCommonTableExpressionBuilder.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FBuilders%2FPrototypes%2FSQLCommonTableExpressionBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvUHJvdG90eXBlcy9TUUxDb21tb25UYWJsZUV4cHJlc3Npb25CdWlsZGVyLnN3aWZ0) | `100.00% <100.00%> (ø)` | | | [...Builders/Prototypes/SQLSubqueryClauseBuilder.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FBuilders%2FPrototypes%2FSQLSubqueryClauseBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvUHJvdG90eXBlcy9TUUxTdWJxdWVyeUNsYXVzZUJ1aWxkZXIuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [...Expressions/Clauses/SQLCommonTableExpression.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FExpressions%2FClauses%2FSQLCommonTableExpression.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvRXhwcmVzc2lvbnMvQ2xhdXNlcy9TUUxDb21tb25UYWJsZUV4cHJlc3Npb24uc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [Sources/SQLKit/Expressions/Queries/SQLDelete.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FExpressions%2FQueries%2FSQLDelete.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvRXhwcmVzc2lvbnMvUXVlcmllcy9TUUxEZWxldGUuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [Sources/SQLKit/Expressions/Queries/SQLInsert.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FExpressions%2FQueries%2FSQLInsert.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvRXhwcmVzc2lvbnMvUXVlcmllcy9TUUxJbnNlcnQuc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | [Sources/SQLKit/Expressions/Queries/SQLSelect.swift](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree&filepath=Sources%2FSQLKit%2FExpressions%2FQueries%2FSQLSelect.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvRXhwcmVzc2lvbnMvUXVlcmllcy9TUUxTZWxlY3Quc3dpZnQ=) | `100.00% <100.00%> (ø)` | | | ... and [2 more](https://app.codecov.io/gh/vapor/sql-kit/pull/179?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | |
gwynne commented 5 months ago

I personally would have liked to have at least 1 test case with a real world complex query.

There, happy? One of them even revealed a bug 😜