You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add LINQ methods for INTERSECT ALL and EXCEPT ALL #16273
We support the four standard set operations (UNION, UNION ALL, INTERSECT, EXCEPT), but PostgreSQL also supports INTERSECT ALL and EXCEPT ALL (which don't return distinct elements, much like UNION ALL). Our current design uses an enum to represent the operation type, so it's not easily extensible by providers. Options include:
Having an Other enum value which allows relational to understand it's a set operation, but also allows providers to specify additional information on its SelectExpression that would allow the correct operation to be rendered to SQL.
Have a SetOperationExpression deriving from SelectExpression, allowing providers to derive from that. However, I'm not clear on the extension/inheritance architecture with regards to providers (who should also be able to extend SelectExpression in order to override logic there?).
Actual need for INTERSECT ALL and EXCEPT ALL isn't likely to be high, so we can also punt this (although it's a pretty fundamental design discussion).
Unrelated note: MySQL only supports UNION and UNION ALL, no INTERSECT or EXCEPT.
FWIW, UNION ALL, UNION DISTINCT, EXCEPT ALL, EXCEPT DISTINCT, INTERSECT ALL, and INTERSECT DISTINCT are all ANSI SQL standard operators. The DISTINCT keyword is optional.
changed the title [-]Set operations: allow defining custom, provider-specific operation types[/-][+]Set operations: support INTERSECT ALL and EXCEPT ALL[/+]on Jun 26, 2019
@roji I think it would be okay to come up new IQueryable<T> extension methods on relational. Providers can choose to re-implement as @mburbea suggests. But it all seems low priority for now.
changed the title [-]Set operations: support INTERSECT ALL and EXCEPT ALL[/-][+]Set operations: Add LINQ method for INTERSECT ALL and EXCEPT ALL[/+]on Mar 16, 2020
changed the title [-]Set operations: Add LINQ method for INTERSECT ALL and EXCEPT ALL[/-][+]Add LINQ methods for INTERSECT ALL and EXCEPT ALL[/+]on Mar 16, 2020
Activity
divega commentedon Jun 26, 2019
FWIW, UNION ALL, UNION DISTINCT, EXCEPT ALL, EXCEPT DISTINCT, INTERSECT ALL, and INTERSECT DISTINCT are all ANSI SQL standard operators. The DISTINCT keyword is optional.
roji commentedon Jun 26, 2019
Great! In that case maybe we can simply include them in our enum and be done with this?
The only issue with EXCEPT ALL and INTERSECT ALL is that there's no LINQ operator for them, so we'd have to add something on EF.Functions or similar?
[-]Set operations: allow defining custom, provider-specific operation types[/-][+]Set operations: support INTERSECT ALL and EXCEPT ALL[/+]mburbea commentedon Jun 26, 2019
Sql server does not support these operators, but a translation for
intersect all/except allcould be done as so::Is equivalent to::
divega commentedon Jun 26, 2019
@roji I think it would be okay to come up new IQueryable<T> extension methods on relational. Providers can choose to re-implement as @mburbea suggests. But it all seems low priority for now.
smitpatel commentedon Aug 21, 2019
Infrastructure changes made to design now supports following.
& all 3 of them with/without Distinct so all 6.
Pending work here is
[-]Set operations: support INTERSECT ALL and EXCEPT ALL[/-][+]Set operations: Add LINQ method for INTERSECT ALL and EXCEPT ALL[/+][-]Set operations: Add LINQ method for INTERSECT ALL and EXCEPT ALL[/-][+]Add LINQ methods for INTERSECT ALL and EXCEPT ALL[/+]