File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,9 +168,26 @@ export default function connect(settings) {
168168 return row ;
169169 }
170170
171- async function raw ( sql , options = { } ) {
172- const dbApi = options . dbApi || knex ;
173- const res = await dbApi . raw ( sql , options ) ;
171+ async function raw ( sql , bindingsOrOptions = { } , options = { } ) {
172+ // Support two call shapes:
173+ // raw(sql) — no bindings
174+ // raw(sql, bindings) — array or object bindings (Knex style)
175+ // raw(sql, bindings, options) — bindings + options.dbApi
176+ // raw(sql, { bindings, dbApi }) — options object with bindings key
177+ let bindings ;
178+ let opts ;
179+ if ( Array . isArray ( bindingsOrOptions ) ) {
180+ bindings = bindingsOrOptions ;
181+ opts = options ;
182+ } else if ( bindingsOrOptions && typeof bindingsOrOptions === 'object' && 'bindings' in bindingsOrOptions ) {
183+ bindings = bindingsOrOptions . bindings ;
184+ opts = bindingsOrOptions ;
185+ } else {
186+ bindings = undefined ;
187+ opts = bindingsOrOptions ;
188+ }
189+ const dbApi = opts . dbApi || knex ;
190+ const res = bindings !== undefined ? await dbApi . raw ( sql , bindings ) : await dbApi . raw ( sql ) ;
174191 return res . rows || res ;
175192 }
176193
Original file line number Diff line number Diff line change 11{
22 "name" : " breadfruit" ,
3- "version" : " 3.1.0 " ,
3+ "version" : " 3.1.1 " ,
44 "description" : " Boilerplate SQL query helpers for Node.js using Knex" ,
55 "type" : " module" ,
66 "main" : " ./index.js" ,
You can’t perform that action at this time.
0 commit comments