We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova [ ] mongodb [ ] mssql [x] mysql / mariadb [ ] oracle [ ] postgres [ ] sqlite [ ] sqljs [ ] react-native [ ] expo
cordova
mongodb
mssql
mysql
mariadb
oracle
postgres
sqlite
sqljs
react-native
expo
TypeORM version:
[ ] latest [ ] @next [x] 0.2.13
latest
@next
0.2.13
Steps to reproduce or a small repository showing the problem:
Models
@Entity() export class Foo { @PrimaryGeneratedColumn() public id?: number; @OneToMany(type => FooBar, foobar => foobar.foo) public fooBars?: FooBar[]; } @Entity() export class Bar { @PrimaryGeneratedColumn() public id?: number; @OneToMany(type => FooBar, foobar => foobar.foo) public fooBars?: FooBar[]; } @Entity() export class FooBar { @ManyToOne(type => Foo, foo => foo.fooBars, { primary: true }) public foo: Foo | null = null; @ManyToOne(type => Bar, bar => bar.fooBars, { primary: true }) public bar: Bar | null = null; }
Data & Query
const mgr = queryRunner.manager; const foo = new Foo(); await mgr.save(foo); const result = await mgr.find(Foo, { relations: ['fooBars', 'fooBars.bar'] }); console.log(JSON.stringify(result, null, 4));
Actual Result
[ { "id": 1, "fooBars": [ { "foo": null, "bar": null } ] } ]
Expected Result
[ { "id": 1, "fooBars": [] } ]
The text was updated successfully, but these errors were encountered:
You can get it working by specyfying FooBar entity a bit different:
@Entity() export class FooBar { @PrimaryColumn() public fooid?: number; @PrimaryColumn() public barid?: number; @ManyToOne(type => Foo, foo => foo.fooBars) @JoinColumn({ name: "fooid"}) public foo: Foo | null = null; @ManyToOne(type => Bar, bar => bar.fooBars) @JoinColumn({ name: "barid"}) public bar: Bar | null = null; }
Also in 0.3.0 defining a primary column will be required for primary keyed relations - #3661 (comment)
0.3.0
Sorry, something went wrong.
It works. Thanks @Kononnable
I can't run migration with this method, maybe someone know another solution
No branches or pull requests
Issue type:
[ ] 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:
[ ]
latest
[ ]
@next
[x]
0.2.13
Steps to reproduce or a small repository showing the problem:
Models
Data & Query
Actual Result
Expected Result
The text was updated successfully, but these errors were encountered: