Skip to content

Commit

Permalink
remove nulls for raw and rely on defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
shogunpurple committed Jan 16, 2025
1 parent c077f7e commit 0b8d024
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/backend-core/src/sql/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,17 +1167,15 @@ class InternalBuilder {
let nulls: "first" | "last" | undefined = undefined
if (
this.client === SqlClient.POSTGRES ||
this.client === SqlClient.ORACLE ||
this.client === SqlClient.SQL_LITE
this.client === SqlClient.ORACLE
) {
nulls = value.direction === SortOrder.ASCENDING ? "first" : "last"
}

if (this.isAggregateField(key)) {
query = query.orderByRaw(`?? ?? nulls ??`, [
query = query.orderByRaw(`?? ??`, [
this.rawQuotedIdentifier(key),
this.knex.raw(direction),
this.knex.raw(nulls as string),
])
} else {
let composite = `${aliased}.${key}`
Expand All @@ -1188,10 +1186,9 @@ class InternalBuilder {
this.knex.raw(nulls as string),
])
} else {
query = query.orderByRaw(`?? ?? nulls ??`, [
query = query.orderByRaw(`?? ??`, [
this.rawQuotedIdentifier(composite),
this.knex.raw(direction),
this.knex.raw(nulls as string),
])
}
}
Expand Down Expand Up @@ -1361,7 +1358,7 @@ class InternalBuilder {
const standardWrap = (select: Knex.Raw): Knex.QueryBuilder => {
subQuery = subQuery
.select(
relationshipFields.map(field => this.rawQuotedIdentifier(field))
relationshipFields.map(this.rawQuotedIdentifier)
)
.limit(getRelationshipLimit())
// @ts-ignore - the from alias syntax isn't in Knex typing
Expand Down

0 comments on commit 0b8d024

Please sign in to comment.