pg-diff icon indicating copy to clipboard operation
pg-diff copied to clipboard

Need support for BYTEA type for data comparison...

Open zxli opened this issue 10 months ago • 1 comments

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')}'`;

zxli avatar Apr 03 '24 07:04 zxli

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.

michaelsogos avatar Jun 06 '24 10:06 michaelsogos