-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[x ] question
[x ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)
With the following setup, relation does not return an empty array, but an object with all properties set to null:
@Entity()
export class MenuItemPrice {
@Column()
price: number;
@ManyToOne(type => Menu, menu => menu.menuItems, { primary: true })
@JoinColumn({ name: 'menu_id' })
menu: Menu;
@ManyToOne(type => MenuItem, menuItem => menuItem.menus, { primary: true })
@JoinColumn({ name: 'menu_item_id' })
menuItem: MenuItem;
}@Entity()
export class Menu {
@PrimaryColumn()
id: number;
@Type(() => MenuItemPrice)
@OneToMany(type => MenuItemPrice, menuItemPrice => menuItemPrice.menu)
menuItems: MenuItemPrice[];
}@Entity()
export class MenuItem {
@PrimaryColumn()
id: number;
@OneToMany(type => MenuItemPrice, menuItemPrice => menuItemPrice.menuItem)
menus: MenuItemPrice[];
}Now, when fetching with e.g. findOne(1) and table Menu has 1 record and table MenuItem has no records, I get the following result, when menuItems property should be just an empty array:
{
"id": 1,
"menuItems": [
{
"price": null,
"menuItem": null
}
]
}Am I doing something wrong or is this expected?
acis, Evadon-Nathan and MardariG