support blob values #211

This commit is contained in:
Jan Prochazka
2022-02-03 14:29:46 +01:00
parent 1d52e02107
commit 7297976843
12 changed files with 112 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
const { SqlDumper, testEqualColumns } = global.DBGATE_TOOLS;
const { SqlDumper, testEqualColumns, arrayToHexString } = global.DBGATE_TOOLS;
class MsSqlDumper extends SqlDumper {
constructor(driver, options) {
@@ -10,7 +10,7 @@ class MsSqlDumper extends SqlDumper {
endCommand() {
if (this.useHardSeparator) {
this.putRaw('\nGO\n');
this.putRaw('\nGO\n');
} else {
super.endCommand();
}
@@ -27,6 +27,10 @@ class MsSqlDumper extends SqlDumper {
super.putStringValue(value);
}
putByteArrayValue(value) {
super.putRaw('0x' + arrayToHexString(value));
}
allowIdentityInsert(table, allow) {
this.putCmd('^set ^identity_insert %f %k', table, allow ? 'on' : 'off');
}

View File

@@ -65,12 +65,8 @@ class Dumper extends SqlDumper {
this.putCmd('^create ^table %f (^select * ^from %f)', targetName, sourceName);
}
putValue(value) {
if (value && value.type == 'Buffer' && _isArray(value.data)) {
this.putRaw(`unhex('${arrayToHexString(value.data)}')`);
} else {
super.putValue(value);
}
putByteArrayValue(value) {
this.putRaw(`unhex('${arrayToHexString(value)}')`);
}
}

View File

@@ -92,6 +92,10 @@ class Dumper extends SqlDumper {
else if (value === false) this.putRaw('false');
else super.putValue(value);
}
putByteArrayValue(value) {
this.putRaw(`e'\\\\x${arrayToHexString(value)}'`);
}
}
module.exports = Dumper;

View File

@@ -8,6 +8,10 @@ class Dumper extends SqlDumper {
renameTable(obj, newname) {
this.putCmd('^alter ^table %f ^rename ^to %i', obj, newname);
}
putByteArrayValue(value) {
this.putRaw(`x'${arrayToHexString(value)}'`);
}
}
module.exports = Dumper;