Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): do not infer
populate: ['*']
from fields: ['*']
Closes #5139
- Loading branch information
Showing
2 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
Entity, | ||
Ref, | ||
ManyToOne, | ||
MikroORM, | ||
PrimaryKey, OneToMany, Collection, | ||
} from '@mikro-orm/sqlite'; | ||
|
||
@Entity() | ||
class City { | ||
|
||
@PrimaryKey() | ||
id!: number; | ||
|
||
@OneToMany(() => School, s => s.city) | ||
schools = new Collection<School>(this); | ||
|
||
} | ||
|
||
@Entity() | ||
class School { | ||
|
||
@PrimaryKey() | ||
id!: number; | ||
|
||
@ManyToOne(() => City, { ref: true }) | ||
city!: Ref<City>; | ||
|
||
} | ||
|
||
|
||
let orm: MikroORM; | ||
|
||
beforeAll(async () => { | ||
orm = await MikroORM.init({ | ||
dbName: ':memory:', | ||
entities: [City], | ||
}); | ||
await orm.schema.createSchema(); | ||
|
||
await orm.em.insert(City, { id: 1 }); | ||
await orm.em.insertMany(School, [ | ||
{ id: 1, city: 1 }, | ||
{ id: 2, city: 1 }, | ||
]); | ||
}); | ||
|
||
afterAll(async () => { | ||
await orm.close(true); | ||
}); | ||
|
||
test(`GH issue 5139`, async () => { | ||
const city = await orm.em.find(City, { id: 1 }, { fields: ['*'] }); | ||
expect(city[0].schools.isInitialized()).toBe(false); | ||
}); |