@@ -163,15 +163,15 @@ function tablesToSQL(tables) {
163
163
if ( baseTable . type === 'dual' ) return 'DUAL' ;
164
164
let str = baseTable . table ? identifierToSql ( baseTable . table ) : exprToSQL ( baseTable . expr ) ;
165
165
166
- if ( baseTable . db && baseTable . db !== null ) str = baseTable . db + '.' + str ;
166
+ if ( baseTable . db ) str = baseTable . db + '.' + str ;
167
167
if ( baseTable . as !== null ) str += ' AS ' + identifierToSql ( baseTable . as ) ;
168
168
169
169
clauses . push ( str ) ;
170
170
171
171
for ( let i = 1 ; i < tables . length ; i ++ ) {
172
172
const joinExpr = tables [ i ] ;
173
173
174
- str = joinExpr . join && joinExpr . join !== null ? ' ' + joinExpr . join + ' ' : ( str = ', ' ) ;
174
+ str = joinExpr . join ? ' ' + joinExpr . join + ' ' : ( str = ', ' ) ;
175
175
176
176
if ( joinExpr . table ) {
177
177
if ( joinExpr . db !== null ) str += joinExpr . db + '.' ;
@@ -212,7 +212,7 @@ function withToSql(withExpr) {
212
212
* @param {Object } stmt
213
213
* @param {?Array } stmt.with
214
214
* @param {?Array } stmt.options
215
- * @param {? string} stmt.distinct
215
+ * @param {string|null } stmt.distinct
216
216
* @param {?Array|string } stmt.columns
217
217
* @param {?Array } stmt.from
218
218
* @param {?Object } stmt.where
@@ -229,8 +229,7 @@ function selectToSQL(stmt) {
229
229
if ( has ( stmt , 'options' ) && Array . isArray ( stmt . options ) ) clauses . push ( stmt . options . join ( ' ' ) ) ;
230
230
if ( has ( stmt , 'distinct' ) && stmt . distinct !== null ) clauses . push ( stmt . distinct ) ;
231
231
232
- if ( stmt . columns !== '*' ) clauses . push ( columnsToSQL ( stmt . columns ) ) ;
233
- else clauses . push ( '*' ) ;
232
+ clauses . push ( stmt . columns !== '*' ? columnsToSQL ( stmt . columns ) : '*' ) ;
234
233
235
234
// FROM + joins
236
235
if ( Array . isArray ( stmt . from ) ) clauses . push ( 'FROM' , tablesToSQL ( stmt . from ) ) ;
0 commit comments