Skip to content

Commit

Permalink
refactor: fix mess created by the merge
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jan 11, 2024
1 parent 0ee3ee6 commit 57d9ca7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
43 changes: 4 additions & 39 deletions test/database/query_builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,41 +451,6 @@ test.group('Query Builder | where', (group) => {
await connection.disconnect()
})

test('add where clause with a null comparison', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), app.logger)
connection.connect()

let db = getQueryBuilder(getQueryClient(connection, app))
const { sql, bindings } = db.from('users').where('username', null).toSQL()

const { sql: knexSql, bindings: knexBindings } = connection
.client!.from('users')
.where('username', null)
.toSQL()

assert.equal(sql, knexSql)
assert.deepEqual(bindings, knexBindings)

/**
* Using keys resolver
*/
db = getQueryBuilder(getQueryClient(connection, app))
db.keysResolver = (key) => `my_${key}`
const { sql: resolverSql, bindings: resolverBindings } = db
.from('users')
.where('username', null)
.toSQL()

const { sql: knexResolverSql, bindings: knexResolverBindings } = connection
.client!.from('users')
.where('my_username', null)
.toSQL()

assert.equal(resolverSql, knexResolverSql)
assert.deepEqual(resolverBindings, knexResolverBindings)
await connection.disconnect()
})

test('wrap where clause to its own group', async ({ assert }) => {
const connection = new Connection('primary', getConfig(), logger)
connection.connect()
Expand Down Expand Up @@ -7020,7 +6985,7 @@ test.group('Query Builder | havingNull', (group) => {
const { sql: knexSql, bindings: knexBindings } = (connection.client as any)
.from('users')
['havingNull']('deleted_at')
['orHavingNull']('updated_at')
.orHavingNull('updated_at')
.toSQL()

assert.equal(sql, knexSql)
Expand All @@ -7038,7 +7003,7 @@ test.group('Query Builder | havingNull', (group) => {
const { sql: knexResolverSql, bindings: knexResolverBindings } = (connection.client as any)
.from('users')
['havingNull']('my_deleted_at')
['orHavingNull']('my_updated_at')
.orHavingNull('my_updated_at')
.toSQL()

assert.equal(resolverSql, knexResolverSql)
Expand Down Expand Up @@ -7110,7 +7075,7 @@ test.group('Query Builder | havingNotNull', (group) => {
.from('users')
.from('users')
['havingNotNull']('deleted_at')
['orHavingNotNull']('updated_at')
.orHavingNotNull('updated_at')
.toSQL()

assert.equal(sql, knexSql)
Expand All @@ -7128,7 +7093,7 @@ test.group('Query Builder | havingNotNull', (group) => {
const { sql: knexResolverSql, bindings: knexResolverBindings } = (connection.client as any)
.from('users')
['havingNotNull']('my_deleted_at')
['orHavingNotNull']('my_updated_at')
.orHavingNotNull('my_updated_at')
.toSQL()

assert.equal(resolverSql, knexResolverSql)
Expand Down
2 changes: 1 addition & 1 deletion test/orm/model_has_many.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3787,7 +3787,7 @@ if (process.env.DB !== 'mysql_legacy') {
User.boot()

const users = await User.query().preload('posts', (query) => {
query.groupLimit(2).groupOrderBy('created_at', 'asc')
query.groupLimit(2).groupOrderBy('created_at', 'desc')
})
assert.lengthOf(users, 2)

Expand Down

0 comments on commit 57d9ca7

Please sign in to comment.