pg-diff
pg-diff copied to clipboard
Need support for BYTEA type for data comparison...
In sqlScriptGenerator.js, BYTEA type will fall back to default user type and result in the error "value.replace is not a function".
case "U": {
//USER TYPE
switch (dataTypeName) {
case "jsonb":
case "json":
return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
case "bytea":
console.log(value.toString('hex'));
return `'\\x${value.toString('hex')}'`;
default:
//like XML, UUID, GEOMETRY, etc.
return `'${value.replace(/'/g, "''")}'`;
}
``
`It could be fixed by a change like this.
case "U": {
//USER TYPE
switch (dataTypeName) {
case "jsonb":
case "json":
return `'${JSON.stringify(value).replace(/'/g, "''")}'`;
case "bytea":
return `'\\x${value.toString('hex')}'`;
Hi @zxli ,
Sure I missed something because the default case must remain, but in the code that you mentioned the case "bytea" is there, so it should not land in the default case.
Let me debug it and I will come back to you soon.