GRDB support for Common Table Expressions

Hello,

The GRDB repository has a pull request which drafts support for SQLite Common Table Expressions.

Please check the documentation of the new feature at https://github.com/groue/GRDB.swift/blob/dev/cte/Documentation/CommonTableExpressions.md

@remcopoelstra, you requested this feature, so I wonder if the pull request looks like it would fulfill your needs.

The opinion of all GRDB users on the proposed apis is, of course, much welcome!

3 Likes

Hi,

Good to see this! I'll try and use this new API to convert one of my raw SQL queries.
This will take some time of course, but I'll report back.

1 Like

I indeed guess you already have working code that uses raw SQL. It will be interesting to know if you feel like the Swift API is an improvement. It's not obvious: sometimes raw SQL is as concise and clear as desired :slightly_smiling_face:

Hi,

I've converted the first few of my CTE queries and it looks quite good. At least it all still works :slight_smile:
There is only one thing that confuses me just a bit and that's the use of .annotated.
When I've a CTE with multiple columns, how do I select a single column to be fetched? It seems I can't use anything like .annotated. Is that correct?

Will you please ask again in https://github.com/groue/GRDB.swift/pull/880, with a practical example? It's not clear yet how you want to use this single column.

Terms of Service

Privacy Policy

Cookie Policy