data duplicator works in simple case

This commit is contained in:
Jan Prochazka
2023-02-11 10:17:10 +01:00
parent f3dd187df7
commit b5e37053b8
17 changed files with 517 additions and 61 deletions

View File

@@ -155,6 +155,10 @@ class MsSqlDumper extends SqlDumper {
newname
);
}
selectScopeIdentity() {
this.put('^select ^scope_identity()');
}
}
MsSqlDumper.prototype.renameView = MsSqlDumper.prototype.renameObject;

View File

@@ -89,6 +89,10 @@ class Dumper extends SqlDumper {
putByteArrayValue(value) {
this.putRaw(`unhex('${arrayToHexString(value)}')`);
}
selectScopeIdentity() {
this.put('^select ^last_insert_id()')
}
}
module.exports = Dumper;

View File

@@ -99,6 +99,14 @@ class Dumper extends SqlDumper {
putByteArrayValue(value) {
this.putRaw(`e'\\\\x${arrayToHexString(value)}'`);
}
selectScopeIdentity(table) {
this.put(
"^SELECT currval(pg_get_serial_sequence('%f','%s'))",
table,
table.columns?.find(x => x.autoIncrement)?.[0]?.columnName
);
}
}
module.exports = Dumper;

View File

@@ -16,6 +16,10 @@ class Dumper extends SqlDumper {
truncateTable(name) {
this.putCmd('^delete ^from %f', name);
}
selectScopeIdentity() {
this.put('^select last_insert_rowid()')
}
}
module.exports = Dumper;