@@ -61,8 +61,8 @@ export class QueryBuilder<GenericResultWrapper> {
6161 return this . execute ( q )
6262 } ,
6363 this . _select ( { ...params , limit : 1 } ) ,
64- typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where . params
65- ? params . where . params
64+ typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where ? .params
65+ ? params . where ? .params
6666 : undefined ,
6767 FetchTypes . ONE
6868 )
@@ -74,8 +74,8 @@ export class QueryBuilder<GenericResultWrapper> {
7474 return this . execute ( q )
7575 } ,
7676 this . _select ( params ) ,
77- typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where . params
78- ? params . where . params
77+ typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where ? .params
78+ ? params . where ? .params
7979 : undefined ,
8080 FetchTypes . ALL
8181 )
@@ -99,10 +99,10 @@ export class QueryBuilder<GenericResultWrapper> {
9999 if (
100100 typeof params . onConflict ?. where === 'object' &&
101101 ! Array . isArray ( params . onConflict ?. where ) &&
102- params . onConflict ?. where . params
102+ params . onConflict ?. where ? .params
103103 ) {
104104 // 1 - on conflict where parameters
105- args = args . concat ( params . onConflict . where . params )
105+ args = args . concat ( params . onConflict . where ? .params )
106106 }
107107
108108 if ( params . onConflict . data ) {
@@ -135,8 +135,8 @@ export class QueryBuilder<GenericResultWrapper> {
135135 update < GenericResult = DefaultObject > ( params : Update ) : Query < ArrayResult < GenericResultWrapper , GenericResult > > {
136136 let args = this . _parse_arguments ( params . data )
137137
138- if ( typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where . params ) {
139- args = ( params . where . params as Array < any > ) . concat ( args )
138+ if ( typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where ? .params ) {
139+ args = ( params . where ? .params as Array < any > ) . concat ( args )
140140 }
141141
142142 return new Query (
@@ -155,8 +155,8 @@ export class QueryBuilder<GenericResultWrapper> {
155155 return this . execute ( q )
156156 } ,
157157 this . _delete ( params ) ,
158- typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where . params
159- ? params . where . params
158+ typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where ? .params
159+ ? params . where ? .params
160160 : undefined ,
161161 FetchTypes . ALL
162162 )
@@ -209,7 +209,7 @@ export class QueryBuilder<GenericResultWrapper> {
209209 if (
210210 typeof params . onConflict ?. where === 'object' &&
211211 ! Array . isArray ( params . onConflict ?. where ) &&
212- params . onConflict ?. where . params
212+ params . onConflict ?. where ? .params
213213 ) {
214214 index += ( params . onConflict . where ?. params ) . length
215215 }
@@ -246,8 +246,8 @@ export class QueryBuilder<GenericResultWrapper> {
246246
247247 _update ( params : Update ) : string {
248248 const whereParamsLength : number =
249- typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where . params
250- ? Object . keys ( params . where . params as Array < any > ) . length
249+ typeof params . where === 'object' && ! Array . isArray ( params . where ) && params . where ? .params
250+ ? Object . keys ( params . where ? .params as Array < any > ) . length
251251 : 0
252252
253253 const set : Array < string > = [ ]
@@ -310,7 +310,11 @@ export class QueryBuilder<GenericResultWrapper> {
310310
311311 if ( typeof conditions === 'string' ) return ` WHERE ${ conditions . toString ( ) } `
312312
313- return ` WHERE ${ ( conditions as Array < string > ) . join ( ' AND ' ) } `
313+ if ( ( conditions as Array < string > ) . length > 0 ) {
314+ return ` WHERE ${ ( conditions as Array < string > ) . join ( ' AND ' ) } `
315+ }
316+
317+ return ''
314318 }
315319
316320 _join ( value ?: Join | Array < Join > ) : string {
0 commit comments