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
Given a multi-schema setup, the QueryBuilder is not respecting the defined schema when querying on a related entity.
Steps to reproduce the behavior:
I'm not sure how to add a test like this, so:
// tests/issues/GH2740.test.tsimport{Collection,Entity,ManyToOne,OneToMany,PrimaryKey,Property,MikroORM}from'@mikro-orm/core';importtype{PostgreSqlDriver}from'@mikro-orm/postgresql';
@Entity({tableName: 'person',schema: 'foo',})exportclassPersonEntity{
@PrimaryKey()id!: number;
@Property()name!: string;}
@Entity({tableName: 'task',schema: 'bar',})exportclassTaskEntity{
@PrimaryKey()id!: number;
@ManyToOne(()=>PersonEntity)person!: PersonEntity;}describe('GH #2740',()=>{letorm: MikroORM<PostgreSqlDriver>;beforeAll(async()=>{orm=awaitMikroORM.init({type: 'postgresql',dbName: 'mikro_orm_test_gh_2740',entities: [PersonEntity,TaskEntity],});awaitorm.getSchemaGenerator().ensureDatabase();awaitorm.getSchemaGenerator().dropSchema();awaitorm.getSchemaGenerator().createSchema();});afterAll(async()=>{awaitorm.close();});it('should respect the defined schema in queries on relations',async()=>{constqb=orm.em.createQueryBuilder(TaskEntity).where({person: {name: 'test'},});expect(qb.getQuery()).toBe(`select "t0".* from "bar"."task" as "t0" left join "foo"."person" as "p1" on "t0"."person_id" = "p1"."id" where "p1"."name" = $1`);});});
$ jest --runInBand tests/issues/GH2740.test.ts
FAIL tests/issues/GH2740.test.ts
GH #2740
✕ should respect the defined schema in queries on relations (9 ms)
● GH #2740 › should respect the defined schema in queries on relations
expect(received).toBe(expected) // Object.is equality
Expected: "select \"t0\".* from \"bar\".\"task\" as \"t0\" left join \"foo\".\"person\" as \"p1\" on \"t0\".\"person_id\" = \"p1\".\"id\" where \"p1\".\"name\" = $1"
Received: "select \"t0\".* from \"bar\".\"task\" as \"t0\" left join \"bar\".\"person\" as \"p1\" on \"t0\".\"person_id\" = \"p1\".\"id\" where \"p1\".\"name\" = $1"
54 | });
55 |
> 56 | expect(qb.getQuery()).toBe(`select "t0".* from "bar"."task" as "t0" left join "foo"."person" as "p1" on "t0"."person_id" = "p1"."id" where "p1"."name" = $1`);
| ^
57 | });
58 |
59 | });
at Object.<anonymous> (tests/issues/GH2740.test.ts:56:27)
Versions
Dependency
Version
@mikro-orm/core
5.0.0
@mikro-orm/postgresql
5.0.0
The text was updated successfully, but these errors were encountered:
Given a multi-schema setup, the QueryBuilder is not respecting the defined schema when querying on a related entity.
Steps to reproduce the behavior:
I'm not sure how to add a test like this, so:
Versions
The text was updated successfully, but these errors were encountered: