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
When model has custom toString() implementation it is not possible to proper use order clause.
Additional typeorm thinks that is ok to sort by method name.
Expected Behavior
Sorting when toString() is defined should be possible
Not possible to sort by defined methods
Actual Behavior
TS2769: No overload matches this call.
Overload 1 of 2, '(options?: FindManyOptions<Transaction>): Promise<Transaction[]>', gave the following error.
Type '{ someMethod: "ASC"; }' is not assignable to type '{ id?: 1 | "ASC" | "DESC" | -1; name?: 1 | "ASC" | "DESC" | -1; toString?: 1 | "ASC" | "DESC" | -1; someMethod?: 1 | "ASC" | "DESC" | -1; }'.
Types of property 'toString' are incompatible.
Type '() => string' is not assignable to type '1 | "ASC" | "DESC" | -1'.
Type '() => string' is not assignable to type '-1'.
Overload 2 of 2, '(conditions?: FindConditions<Transaction>): Promise<Transaction[]>', gave the following error.
Argument of type '{ order: { someMethod: string; }; where: { id: number; }; }' is not assignable to parameter of type 'FindConditions<Transaction>'.
Object literal may only specify known properties, and 'order' does not exist in type 'FindConditions<Transaction>'.
Steps to Reproduce
import {Column, Entity, EntityRepository, PrimaryGeneratedColumn, Repository} from 'typeorm';
@Entity('Transactions')
class Transaction {
@PrimaryGeneratedColumn()
public id?: number;
@Column()
public name?: string;
// when defined there is ERROR in find call, below
public toString() {
return `${this.name}`;
}
public someMethod() {
return 123;
}
}
@EntityRepository(Transaction)
class TransactionsRepository extends Repository<Transaction> {
}
const repo = new TransactionsRepository();
repo.find({
order: {
someMethod: 'ASC', // wrong usage, but for typeorm it is ok
},
where: {
id: 1,
},
});
My Environment
Dependency
Version
Operating System
macos
Node.js version
v12.18.0
Typescript version
v3.9.7
TypeORM version
v0.2.29
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?
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, although I believe I could do it if I had the time...
No, I don't have the time and I wouldn't even know how to start.
The text was updated successfully, but these errors were encountered:
Issue Description
When model has custom toString() implementation it is not possible to proper use order clause.
Additional typeorm thinks that is ok to sort by method name.
Expected Behavior
Actual Behavior
Steps to Reproduce
My Environment
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: