mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 12:06:00 +00:00
fixes sqlite autoincrement column creation
This commit is contained in:
@@ -244,16 +244,7 @@ export class SqlDumper implements AlterProcessor {
|
||||
this.put('%i ', col.columnName);
|
||||
this.columnDefinition(col);
|
||||
});
|
||||
if (table.primaryKey) {
|
||||
this.put(',&n');
|
||||
if (table.primaryKey.constraintName) {
|
||||
this.put('^constraint %i', table.primaryKey.constraintName);
|
||||
}
|
||||
this.put(
|
||||
' ^primary ^key (%,i)',
|
||||
table.primaryKey.columns.map(x => x.columnName)
|
||||
);
|
||||
}
|
||||
this.createTablePrimaryKeyCore(table);
|
||||
|
||||
(table.foreignKeys || []).forEach(fk => {
|
||||
this.put(',&n');
|
||||
@@ -275,6 +266,19 @@ export class SqlDumper implements AlterProcessor {
|
||||
});
|
||||
}
|
||||
|
||||
createTablePrimaryKeyCore(table: TableInfo) {
|
||||
if (table.primaryKey) {
|
||||
this.put(',&n');
|
||||
if (table.primaryKey.constraintName) {
|
||||
this.put('^constraint %i', table.primaryKey.constraintName);
|
||||
}
|
||||
this.put(
|
||||
' ^primary ^key (%,i)',
|
||||
table.primaryKey.columns.map(x => x.columnName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
createForeignKeyFore(fk: ForeignKeyInfo) {
|
||||
if (fk.constraintName != null) this.put('^constraint %i ', fk.constraintName);
|
||||
this.put(
|
||||
|
||||
@@ -18,7 +18,23 @@ class Dumper extends SqlDumper {
|
||||
}
|
||||
|
||||
selectScopeIdentity() {
|
||||
this.put('^select last_insert_rowid()')
|
||||
this.put('^select last_insert_rowid()');
|
||||
}
|
||||
|
||||
columnDefinition(column, flags) {
|
||||
if (column.dataType && column.dataType.toLowerCase().includes('int') && column.notNull && column.autoIncrement) {
|
||||
this.put('^integer ^primary ^key ^autoincrement');
|
||||
return;
|
||||
}
|
||||
super.columnDefinition(column, flags);
|
||||
}
|
||||
|
||||
createTablePrimaryKeyCore(table) {
|
||||
const column = table.columns.find((x) => x.autoIncrement);
|
||||
if (column && column.dataType && column.dataType.toLowerCase().includes('int') && column.notNull) {
|
||||
return;
|
||||
}
|
||||
super.createTablePrimaryKeyCore(table);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user