Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
([expr, ascending, nullsFirst]) =>
sql.fragment`${expr} ${
Number(ascending) ^ Number(flip)
? sql.fragment`ASC`
: sql.fragment`DESC`
}${
nullsFirst === true
? sql.fragment` NULLS FIRST`
: nullsFirst === false
? sql.fragment` NULLS LAST`
: sql.blank
}`
),
return this.buildSelectJson({ addNullCase, addNotDistinctFromNullCase });
}
const { limit, offset, flip } = this.getFinalLimitAndOffset();
const fields =
asJson || asJsonAggregate
? sql.fragment`${this.buildSelectJson({
addNullCase,
addNotDistinctFromNullCase,
})} as object`
: this.buildSelectFields();
let fragment = sql.fragment`\
select ${useAsterisk ? sql.fragment`${this.getTableAlias()}.*` : fields}
${(this.compiledData.from &&
sql.fragment`from ${this.compiledData.from[0]} as ${this.getTableAlias()}`) ||
sql.blank}
${(this.compiledData.join.length && sql.join(this.compiledData.join, " ")) ||
sql.blank}
where ${this.buildWhereClause(true, true, options)}
${
this.compiledData.orderBy.length
? sql.fragment`order by ${sql.join(
this.compiledData.orderBy.map(
([expr, ascending, nullsFirst]) =>
sql.fragment`${expr} ${
Number(ascending) ^ Number(flip)
? sql.fragment`ASC`
: sql.fragment`DESC`
}${
nullsFirst === true
? sql.fragment` NULLS FIRST`
: nullsFirst === false