-
Hi, I've searched the docs and couldn't find information about subqueries. Is it possible to do selects like this in code:
And also joins like this in code:
Or, if those are not supported right now, is there any open classes that I can (safely) subclass or override? or like alter the final generated SQL language? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Of course, those queries are fully supported in moor files where SQL is analyzed at compile-time to generate result classes. Unfortunately, we can't generally support those features in Dart. To be safe, we'd have to generate a new result class for each subquery since it can introduce a new result set not covered by an existing class. That's not the case in the examples you posted and we could support subqueries where we select all columns from an existing table. It's just that those subqueries aren't particularly useful in practice, since you can also write them as regular joins.
You could try writing a subclass of I can't guarantee that this will work, but that sounds like the most promising approach with the current design. |
Beta Was this translation helpful? Give feedback.
Of course, those queries are fully supported in moor files where SQL is analyzed at compile-time to generate result classes.
Unfortunately, we can't generally support those features in Dart. To be safe, we'd have to generate a new result class for each subquery since it can introduce a new result set not covered by an existing class. That's not the case in the examples you posted and we could support subqueries where we select all columns from an existing table. It's just that those subqueries aren't particularly useful in practice, since you can also write them as regular joins.