@@ -64,12 +64,16 @@ export class Statement<T> {
6464 if ( args ?. length > 0 ) {
6565 // apply new bindings then execute
6666 this . bind ( ...args , ( ) => {
67- this . _database . run ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback )
67+ const query = this . _preparedSql . query || ''
68+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] ]
69+ this . _database . run ( query , ...parametes , callback )
6870 } )
6971 } else {
7072 // execute prepared sql with same bindings
71- this . _database . run ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback )
72- }
73+ const query = this . _preparedSql . query || ''
74+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] ]
75+ this . _database . run ( query , ...parametes , callback )
76+ }
7377
7478 return this
7579 }
@@ -89,12 +93,16 @@ export class Statement<T> {
8993 if ( args ?. length > 0 ) {
9094 // apply new bindings then execute
9195 this . bind ( ...args , ( ) => {
92- this . _database . get ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback )
96+ const query = this . _preparedSql . query || ''
97+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] ]
98+ this . _database . get ( query , ...parametes , callback )
9399 } )
94100 } else {
95101 // execute prepared sql with same bindings
96- this . _database . get ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback )
97- }
102+ const query = this . _preparedSql . query || ''
103+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] ]
104+ this . _database . get ( query , ...parametes , callback )
105+ }
98106
99107 return this
100108 }
@@ -111,12 +119,16 @@ export class Statement<T> {
111119 if ( args ?. length > 0 ) {
112120 // apply new bindings then execute
113121 this . bind ( ...args , ( ) => {
114- this . _database . all ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback )
122+ const query = this . _preparedSql . query || ''
123+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] ]
124+ this . _database . all ( query , ...parametes , callback )
115125 } )
116126 } else {
117127 // execute prepared sql with same bindings
118- this . _database . all ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback )
119- }
128+ const query = this . _preparedSql . query || ''
129+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] ]
130+ this . _database . all ( query , ...parametes , callback )
131+ }
120132
121133 return this
122134 }
@@ -133,12 +145,16 @@ export class Statement<T> {
133145 if ( args ?. length > 0 ) {
134146 // apply new bindings then execute
135147 this . bind ( ...args , ( ) => {
136- this . _database . each ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback , complete as RowCountCallback )
148+ const query = this . _preparedSql . query || ''
149+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] , ...[ callback , complete as RowCountCallback ] ]
150+ this . _database . each ( query , ...parametes )
137151 } )
138152 } else {
139153 // execute prepared sql with same bindings
140- this . _database . each ( this . _preparedSql . query || '' , this . _preparedSql . parameters , callback , complete as RowCountCallback )
141- }
154+ const query = this . _preparedSql . query || ''
155+ const parametes : any = [ ...this . _preparedSql . parameters ?? [ ] , ...[ callback , complete as RowCountCallback ] ]
156+ this . _database . each ( query , ...parametes )
157+ }
142158
143159 return this
144160 }
0 commit comments