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
Package versions and database engine type (please complete the following information):
Database Engine: postgres
TypeORM Version: 0.2.41
Driver Version: 2.3.5
Describe the bug
When you have a repository query that uses the relation option to load related entities where the relation relies on a uuid field, the query will fail unless enableUuidHack is set to true
You'll get
BadRequestException: ERROR: operator does not exist: uuid = character varying
Presumably because the ids on the relations are not casted a uuid
To Reproduce
@Entity()
export default class A {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
name: string
@Column()
bId: string;
@ManyToOne(() => B)
@JoinColumn({ name: 'bId' })
b: B;
}
@Entity()
export default class B {
@PrimaryGeneratedColumn('uuid')
id: string;
@OneToMany(() => A, a => a.b)
a: Array<A>;
}
// create connection without passing `formatOptions` (i.e. enableUuidHack is false)
createConnection({
type: 'aurora-data-api-pg',
database: '...',
secretArn:'...',
region: '...',
entities: [
A,
B
],
});
// A custom repo
@EntityRepository(A)
export class ARepository extends Repository<A> {
findByName(
name: A['name'],
): Promise<A | undefined> {
return this.findOne({
where: { name },
relations: ['b'],
});
}
}
// use the repo method, it will fail with
// BadRequestException: ERROR: operator does not exist: uuid = character varying
const result = await getCustomRepository(ARepository).findByName('a name')
The text was updated successfully, but these errors were encountered:
Package versions and database engine type (please complete the following information):
Describe the bug
When you have a repository query that uses the
relation
option to load related entities where the relation relies on a uuid field, the query will fail unlessenableUuidHack
is set totrue
You'll get
Presumably because the ids on the relations are not casted a
uuid
To Reproduce
The text was updated successfully, but these errors were encountered: