Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shogunpurple committed Jan 16, 2025
1 parent c69e604 commit d610317
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
43 changes: 22 additions & 21 deletions packages/backend-core/src/sql/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,31 +1162,32 @@ class InternalBuilder {
const direction =
value.direction === SortOrder.ASCENDING ? "asc" : "desc"

let nulls: "first" | "last" =
value.direction === SortOrder.ASCENDING ? "first" : "last"
// TODO: figure out a way to remove this conditional, not relying on
// the defaults of each datastore.
let nulls: "first" | "last" | undefined = undefined
if (
this.client === SqlClient.POSTGRES ||
this.client === SqlClient.ORACLE
) {
nulls = value.direction === SortOrder.ASCENDING ? "first" : "last"
}

const composite = `${aliased}.${key}`
let identifier

if (this.isAggregateField(key)) {
query = query.orderByRaw(`?? ?? nulls ??`, [
this.rawQuotedIdentifier(key),
this.knex.raw(direction),
this.knex.raw(nulls as string),
])
identifier = this.rawQuotedIdentifier(key)
} else if (this.client === SqlClient.ORACLE) {
identifier = this.convertClobs(composite)
} else {
let composite = `${aliased}.${key}`
if (this.client === SqlClient.ORACLE) {
query = query.orderByRaw(`?? ?? nulls ??`, [
this.convertClobs(composite),
this.knex.raw(direction),
this.knex.raw(nulls as string),
])
} else {
query = query.orderByRaw(`?? ?? nulls ??`, [
this.rawQuotedIdentifier(composite),
this.knex.raw(direction),
this.knex.raw(nulls as string),
])
}
identifier = this.rawQuotedIdentifier(composite)
}

query = query.orderByRaw(`?? ?? ${nulls ? "nulls ??" : ""}`, [
identifier,
this.knex.raw(direction),
...(nulls ? [this.knex.raw(nulls as string)] : []),
])
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/server/src/integrations/microsoftSqlServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
encrypt,
enableArithAbort: true,
requestTimeout: env.QUERY_THREAD_TIMEOUT,
connectTimeout: env.QUERY_THREAD_TIMEOUT,
},
}
if (encrypt) {
Expand Down

0 comments on commit d610317

Please sign in to comment.