File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,9 @@ export const createBridge = (postgres: typeof Postgres) => {
9797 } ,
9898 off : connection . events . off . bind ( connection . events ) ,
9999 on : connection . events . on . bind ( connection . events ) ,
100- query : async ( sql : string ) : Promise < QueryResult > => {
100+ query : async ( sql : string , parameters ) : Promise < QueryResult > => {
101101 // https://github.com/porsager/postgres#result-array
102- const resultArray = await connection . unsafe ( sql ) ;
102+ const resultArray = await connection . unsafe ( sql , parameters ) ;
103103
104104 return {
105105 command : resultArray . command as Command ,
Original file line number Diff line number Diff line change @@ -132,4 +132,28 @@ for (const client of clients) {
132132 name : '?column?' ,
133133 } ) ;
134134 } ) ;
135+
136+ test ( client + ': query method with parameters' , async ( t ) => {
137+ const pool = createPool ( client , {
138+ user : 'postgres' ,
139+ } ) ;
140+
141+ const connection = await pool . connect ( ) ;
142+
143+ const result = await connection . query ( 'SELECT $1' , [
144+ 'foo' ,
145+ ] ) ;
146+
147+ t . is ( result . rows . length , 1 ) ;
148+ t . is ( result . command , 'SELECT' ) ;
149+ t . like ( result . rows [ 0 ] ,
150+ {
151+ '?column?' : 'foo' ,
152+ } ) ;
153+ t . like ( result . fields [ 0 ] ,
154+ {
155+ dataTypeID : 25 ,
156+ name : '?column?' ,
157+ } ) ;
158+ } ) ;
135159}
You can’t perform that action at this time.
0 commit comments