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
We are trying to create a OneToOne relation with referencedColumnName where the relation is not between primary keys, its between two unique strings. See example below
@Entity()
class Exercise {
@PrimaryGeneratedColumn()
public id: number;
@Column('string')
public key: string;
@OneToOne((type) => Atom, (atom) => atom.exercise)
public atom: Atom;
}
@Entity()
class Atom {
@PrimaryGeneratedColumn()
public id: number;
@Column('string')
public key: string;
@Column('string')
public exercise_key: string;
@OneToOne((type) => Exercise, (exercise) => exercise.atom)
@JoinColumn({ name: 'exercise_key', referencedColumnName: 'key' })
public exercise: Exercise
}
When typeorm tries to create the schema we get an error saying that MySQL could not create the foreign key. We debugged it and saw that ForeignKeySchema.referencedColumnNames = ['id'] and not ForeignKeySchema.referencedColumnNames = ['key'], but I don't know if that's a part of the problem.
The text was updated successfully, but these errors were encountered:
________________________________
Från: Umed Khudoiberdiev <notifications@github.com>
Skickat: den 24 mars 2017 13:26:19
Till: typeorm/typeorm
Kopia: Jacob Söderblom; Author
Ämne: Re: [typeorm/typeorm] OneToOne relation with referencedColumnName does not work (#341)
that was a bug. Fixed and released in 0.0.11. Make sure to setup your entities exactly like in test in 08c1ee1<08c1ee1>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#341 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AHP76lUnidwlPgoa2Fa1ii9Gg0VRTeXaks5ro7ZrgaJpZM4MbGib>.
We are trying to create a OneToOne relation with referencedColumnName where the relation is not between primary keys, its between two unique strings. See example below
When typeorm tries to create the schema we get an error saying that MySQL could not create the foreign key. We debugged it and saw that
ForeignKeySchema.referencedColumnNames = ['id']
and notForeignKeySchema.referencedColumnNames = ['key']
, but I don't know if that's a part of the problem.The text was updated successfully, but these errors were encountered: