ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Left joining on any table should not require an order by column to exist in select clause
This column is not mandatory in a select clause for this query to work!
^
|
|
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName; <------- order by CustomerName
Actual Behavior
Typeorm requires a column(say "CustomerName") to exist on select clause for order by CustomerName to work when doing left join using relations options (relations:['Orders'])
{ ....
"message": "column distinctAlias.Customers_CustomerName does not exist",
"stack": "QueryFailedError: column distinctAlias.Customers_CustomerName does not exist\n at PostgresQueryRunner.query "
.....
}
PS: query works fine if the relations option is not provided.
Steps to Reproduce
Create an Entity with a ManyToOne column and any column (say "CustomerName") with @Column({select:false}).
Run a Find query {order: {CustomerName:"DESC"}, relations:["Orders"]}
My Environment
Dependency
Version
Operating System
PopOS 22.04
Node.js version
v14.17.0
Typescript version
4.5.2
TypeORM version
0.3.6
Additional Context
Relevant Database Driver(s)
DB Type
Reproducible
aurora-mysql
no
aurora-postgres
no
better-sqlite3
no
cockroachdb
no
cordova
no
expo
no
mongodb
no
mysql
no
nativescript
no
oracle
no
postgres
yes
react-native
no
sap
no
spanner
no
sqlite
no
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.
Expected Behavior
Left joining on any table should not require an
order by
column to exist inselect
clauseActual Behavior
Typeorm requires a column(say "CustomerName") to exist on
select
clause fororder by CustomerName
to work when doingleft join
usingrelations
options (relations:['Orders']
)PS: query works fine if the
relations
option is not provided.Steps to Reproduce
ManyToOne
column and any column (say "CustomerName") with@Column({select:false})
.{order: {CustomerName:"DESC"}, relations:["Orders"]}
My Environment
Additional Context
Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?