#182 support for MySQL binary keys

This commit is contained in:
Jan Prochazka
2021-10-17 10:24:31 +02:00
parent 30cbcd5ce0
commit 2231bc21cd
6 changed files with 28 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
const { SqlDumper } = global.DBGATE_TOOLS;
const { SqlDumper, toHexString } = global.DBGATE_TOOLS;
const _isArray = require('lodash/isArray');
class Dumper extends SqlDumper {
/** @param type {import('dbgate-types').TransformType} */
@@ -63,6 +64,11 @@ class Dumper extends SqlDumper {
selectTableIntoNewTable(sourceName, targetName) {
this.putCmd('^create ^table %f (^select * ^from %f)', targetName, sourceName);
}
putValue(value) {
if (value.type == 'Buffer' && _isArray(value.data)) this.putRaw(`unhex('${toHexString(value.data)}')`);
else super.putValue(value);
}
}
module.exports = Dumper;