Skip to content

Commit

Permalink
fix(knex): Only apply default order for MSSQL (#3145)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Apr 5, 2023
1 parent 3eb7428 commit 28c2627
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/knex/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class KnexAdapter<
}

// provide default sorting if its not set
if (!filters.$sort) {
if (!filters.$sort && builder.client.driverName === 'mssql') {
builder.orderBy(`${name}.${id}`, 'asc')
}

Expand Down Expand Up @@ -238,7 +238,7 @@ export class KnexAdapter<
return Promise.all(data.map((current) => this._create(current, params)))
}

const client = this.db(params).client.config.client
const { client } = this.db(params).client.config
const returning = RETURNING_CLIENTS.includes(client as string) ? [this.id] : []
const rows: any = await this.db(params).insert(data, returning).catch(errorHandler)
const id = data[this.id] || rows[0][this.id] || rows[0]
Expand Down

0 comments on commit 28c2627

Please sign in to comment.