mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fixed issue with onDelete not working in sqllite
This commit is contained in:
parent
56373e84c0
commit
94d3b218a3
@ -83,6 +83,10 @@ export class SqliteDriver implements Driver {
|
||||
connection: connection,
|
||||
isTransactionActive: false
|
||||
};
|
||||
|
||||
// we need to enable foreign keys in sqlite to make sure all foreign key related features
|
||||
// working properly. this also makes onDelete to work with sqlite.
|
||||
connection.run(`PRAGMA foreign_keys = ON`);
|
||||
ok();
|
||||
});
|
||||
});
|
||||
|
||||
@ -562,6 +562,7 @@ export class SqliteQueryRunner implements QueryRunner {
|
||||
const columnNames = foreignKey.columnNames.map(name => `"${name}"`).join(", ");
|
||||
const referencedColumnNames = foreignKey.referencedColumnNames.map(name => `"${name}"`).join(", ");
|
||||
sql1 += `, FOREIGN KEY(${columnNames}) REFERENCES "${foreignKey.referencedTableName}"(${referencedColumnNames})`;
|
||||
if (foreignKey.onDelete) sql1 += " ON DELETE " + foreignKey.onDelete;
|
||||
});
|
||||
|
||||
const primaryKeyColumns = tableSchema.columns.filter(column => column.isPrimary && !column.isGenerated);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user