From 2d626529e59641983526e7b188da1ca773a5407f Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 8 May 2021 20:03:18 +0100 Subject: [PATCH] Byte strings in postgres aren't 0x... Byte strings in postgres are actually E'\x...' not 0x... This is part of the follow-up to #1872 Signed-off-by: Andrew Thornton --- dialects/postgres.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dialects/postgres.go b/dialects/postgres.go index 2b234c66..e76e5b7e 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -824,6 +824,11 @@ func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) { } } +// FormatBytes formats bytes +func (db *postgres) FormatBytes(bs []byte) string { + return fmt.Sprintf("E'\\x%x'", bs) +} + func (db *postgres) SQLType(c *schemas.Column) string { var res string switch t := c.SQLType.Name; t {