@@ -57,7 +57,9 @@ export class QueryBuilder<Tables, T = any> {
5757 return `${ ( data as any ) [ key ] } ` ;
5858 } ) ;
5959
60- this . query += `INSERT INTO ${ tableName } (${ this . createKeys ( data ) } ) VALUES (${ this . createValues ( data ) } ) ` ;
60+ this . query += `INSERT INTO ${ tableName } (${ this . createKeys ( data ) } ) VALUES (${ this . createValues (
61+ data ,
62+ ) } ) `;
6163 this . values . push ( ...values ) ;
6264
6365 return this ;
@@ -220,7 +222,11 @@ export class QueryBuilder<Tables, T = any> {
220222 isbn: int({ nullable: false, length: 50 }),
221223 }).exec()
222224 */
223- createTable ( name : string , primary : keyof T | undefined , columns : Partial < Record < keyof T , string > > ) {
225+ createTable (
226+ name : string ,
227+ primary : keyof T | undefined ,
228+ columns : Partial < Record < keyof T , string > > ,
229+ ) {
224230 const primaryKey = primary ? `, PRIMARY KEY (${ primary } )` : "" ;
225231 const values = this . createTableValues ( columns ) ;
226232
@@ -233,7 +239,11 @@ export class QueryBuilder<Tables, T = any> {
233239 * same as `QueryBuilder#createTable` but only create the table if it doesn't exist
234240 * @see [https://github.com/Dev-CasperTheGhost/mysql.ts/blob/main/docs/Query.md#create-table](https://github.com/Dev-CasperTheGhost/mysql.ts/blob/main/docs/Query.md#create-table)
235241 */
236- createTableIfNotExists ( name : string , primary : keyof T | undefined , columns : Partial < Record < keyof T , string > > ) {
242+ createTableIfNotExists (
243+ name : string ,
244+ primary : keyof T | undefined ,
245+ columns : Partial < Record < keyof T , string > > ,
246+ ) {
237247 const primaryKey = primary ? `, PRIMARY KEY (${ primary } )` : "" ;
238248 const values = this . createTableValues ( columns ) ;
239249
@@ -279,7 +289,7 @@ export class QueryBuilder<Tables, T = any> {
279289 /**
280290 * execute the query
281291 */
282- async exec ( options ?: Omit < mysql . QueryOptions , "sql" | "values" > ) : Promise < T [ ] | undefined > {
292+ async exec ( options ?: Omit < mysql . QueryOptions , "sql" | "values" > ) : Promise < ( T | undefined ) [ ] > {
283293 if ( this . config . debugExec === true ) {
284294 console . info ( `[mysql.ts]: Query: ${ this . query } ` ) ;
285295 console . info ( "[mysql.ts]: Values: " , this . values ) ;
@@ -299,13 +309,7 @@ export class QueryBuilder<Tables, T = any> {
299309 return reject ( err ) ;
300310 }
301311
302- if ( this . config . returnEmptyArrayForNoResults ) {
303- return resolve ( results ) ;
304- } else {
305- if ( results . length <= 0 ) {
306- return resolve ( undefined ) ;
307- }
308- }
312+ return resolve ( results ) ;
309313 } ) ;
310314 } ) ;
311315 }
0 commit comments