-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[ ] question
[x ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[x ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[ x] 0.2.25
Steps to reproduce or a small repository showing the problem:
Specifying joinColumn in the @JoinTable() decorator does not pass the inverse join column referenced column width.
@Entity()
export class FooEntity {
@PrimaryColumn({ type: "int", width: 10, unsigned: true, nullable: false })
@Generated()
public id: number;
@ManyToMany(() => BarEntity)
@JoinTable({
name: "foo_bars",
joinColumns: [
{
name: "foo_id",
}
],
inverseJoinColumns: [
{
name: "bar_id",
}
]
})
public fooBars: BarEntity[];
}
@Entity()
export class BarEntity {
@PrimaryColumn({ type: "int", width: 10, unsigned: true })
@Generated()
public id: number;
@Column("varchar", { nullable: false, length: 50 })
public code: string;
}The JunctionEntityMetadataBuilder build() implementation does not pass the 'width' as an arg.
suggested change:
options: {
length: !inverseReferencedColumn.length
&& (this.connection.driver instanceof MysqlDriver || this.connection.driver instanceof AuroraDataApiDriver)
&& (inverseReferencedColumn.generationStrategy === "uuid" || inverseReferencedColumn.type === "uuid")
? "36"
: inverseReferencedColumn.length, // fix https://github.com/typeorm/typeorm/issues/3604
width: inverseReferencedColumn.width,
type: inverseReferencedColumn.type,
precision: inverseReferencedColumn.precision,
scale: inverseReferencedColumn.scale,
charset: inverseReferencedColumn.charset,
collation: inverseReferencedColumn.collation,
zerofill: inverseReferencedColumn.zerofill,
unsigned: inverseReferencedColumn.zerofill ? true : inverseReferencedColumn.unsigned,
name: columnName,
nullable: false,
primary: true,
}
Metadata
Metadata
Assignees
Labels
No labels