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
I would like for support to be added for the INTERSECT, UNION, and EXCEPT operators for Postgres/MySQL.
Unfortunately, there is currently no way to build such queries, without using raw queries.
These operators are very situationally useful, and would enhance querying capabilities for TypeORM.
The Solution
I think the best way to implement the change would be to extend the functionality of the SelectQueryBuilder to include these operators as functions:
for example, for given sql:
select id as t1_id from table1
INTERSECT
select table1_id as t1_id from table2
For INTERSECT, I considered combining inner joins with distinct.
For UNIONS, I created two different queries, and appended their results in the back end.
For EXCEPT, I have yet to encounter a use case while working with TypeORM, therefore I have no good idea for a workaround.
There is a workaround that I picked up from a related issue from 2018, which is linked as additional context.
Additional Context
The feature has been partially requested and closed in the past, without explanation about the rejection: #2992
Relevant Database Driver(s)
DB Type
Relevant
aurora-data-api
no
aurora-data-api-pg
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
yes
nativescript
no
oracle
yes
postgres
yes
react-native
no
sap
no
sqlite
yes
sqlite-abstract
no
sqljs
no
sqlserver
no
Are you willing to resolve this issue by submitting a Pull Request?
✅ Yes, I have the time, and I know how to start.
✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
✖️ No, I don’t have the time, but I can support (using donations) development.
✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
The full syntax for set operators is <UNION | EXCEPT | INTERSECT> [ALL | DISTINCT]. DISTINCT is implicit in most dialects, but ALL needs to be explicitly added if you don't want to filter duplicate results. Most dialects only support UNION ALL (MS SqlServer, Oracle, SAP HANA, Sqlite don't have EXCEPT ALL or INTERSECT ALL in their docs), while some dialects use MINUS instead of EXCEPT (Oracle only?)
Feature Description
The Problem
I would like for support to be added for the INTERSECT, UNION, and EXCEPT operators for Postgres/MySQL.
Unfortunately, there is currently no way to build such queries, without using raw queries.
These operators are very situationally useful, and would enhance querying capabilities for TypeORM.
The Solution
I think the best way to implement the change would be to extend the functionality of the SelectQueryBuilder to include these operators as functions:
for example, for given sql:
either:
or:
Considered Alternatives
For INTERSECT, I considered combining inner joins with distinct.
For UNIONS, I created two different queries, and appended their results in the back end.
For EXCEPT, I have yet to encounter a use case while working with TypeORM, therefore I have no good idea for a workaround.
There is a workaround that I picked up from a related issue from 2018, which is linked as additional context.
Additional Context
The feature has been partially requested and closed in the past, without explanation about the rejection: #2992
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: