File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,11 @@ export class QueryFormatter {
136136 }
137137
138138 private escapeBuffer ( param : Buffer ) {
139- return "'\\x" + param . toString ( "hex" ) + "'" ;
139+ const bytesFormatted = [ ] ;
140+ for ( let i = 0 ; i < param . length ; i ++ ) {
141+ bytesFormatted . push ( "\\x" + param [ i ] . toString ( 16 ) . padStart ( 2 , "0" ) ) ;
142+ }
143+ return "E'" + bytesFormatted . join ( "" ) + "'" ;
140144 }
141145
142146 private escapeArray ( param : unknown [ ] , prefix = "[" , suffix = "]" ) {
Original file line number Diff line number Diff line change @@ -273,7 +273,7 @@ describe("format query", () => {
273273 const formattedQuery = queryFormatter . formatQuery ( query , [ buffer ] ) ;
274274 // Jest escaping rules are different, so we need to double the amount of quotes compared to .toEqual()
275275 expect ( formattedQuery ) . toMatchInlineSnapshot (
276- `"SELECT 'hello_world'::bytea == '\\\\x68656c6c6f5f776f726c64 '"`
276+ `"SELECT 'hello_world'::bytea == E '\\\\x68\\\\x65\\\\x6c\\\\x6c\\\\x6f\\\\x5f\\\\x77\\\\x6f\\\\x72\\\\x6c\\\\x64 '"`
277277 ) ;
278278 } ) ;
279279} ) ;
You can’t perform that action at this time.
0 commit comments