mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 17:16:01 +00:00
support blob values #211
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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)}')`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user