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) => {
97
97
} ,
98
98
off : connection . events . off . bind ( connection . events ) ,
99
99
on : connection . events . on . bind ( connection . events ) ,
100
- query : async ( sql : string ) : Promise < QueryResult > => {
100
+ query : async ( sql : string , parameters ) : Promise < QueryResult > => {
101
101
// https://github.com/porsager/postgres#result-array
102
- const resultArray = await connection . unsafe ( sql ) ;
102
+ const resultArray = await connection . unsafe ( sql , parameters ) ;
103
103
104
104
return {
105
105
command : resultArray . command as Command ,
Original file line number Diff line number Diff line change @@ -132,4 +132,28 @@ for (const client of clients) {
132
132
name : '?column?' ,
133
133
} ) ;
134
134
} ) ;
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
+ } ) ;
135
159
}
You can’t perform that action at this time.
0 commit comments