Skip to content

Commit

Permalink
chore: deprecated if and call usage at tests (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaumlemos authored Apr 24, 2023
1 parent b529407 commit 8b1cede
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion test/node/src/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ for (const dialect of DIALECTS) {
.deleteFrom('person')
.where('gender', '=', 'female')
.returning('first_name')
.if(condition, (qb) => qb.returning('last_name'))
.$if(condition, (qb) => qb.returning('last_name'))

testSql(query, dialect, {
postgres: {
Expand Down
2 changes: 1 addition & 1 deletion test/node/src/group-by.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ for (const dialect of DIALECTS) {
const result = await ctx.db
.selectFrom('person')
.select('person.first_name')
.if(filterByPetCount, (qb) =>
.$if(filterByPetCount, (qb) =>
qb
.innerJoin('pet', 'pet.owner_id', 'person.id')
.having(count('pet.id'), '>', 1)
Expand Down
2 changes: 1 addition & 1 deletion test/node/src/insert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ for (const dialect of DIALECTS) {
gender: 'other',
})
.returning('first_name')
.if(condition, (qb) => qb.returning('last_name'))
.$if(condition, (qb) => qb.returning('last_name'))

const result = await query.executeTakeFirstOrThrow()

Expand Down
4 changes: 2 additions & 2 deletions test/node/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ for (const dialect of DIALECTS) {
const builder = ctx.db.schema
.createTable('test')
.addColumn('id', 'integer', (col) => col.notNull())
.call((builder) =>
.$call((builder) =>
builder.addColumn('call_me', 'varchar(10)', (col) =>
col.defaultTo('maybe')
)
Expand Down Expand Up @@ -2447,7 +2447,7 @@ for (const dialect of DIALECTS) {
it('should alter a table calling query builder functions', async () => {
const builder = ctx.db.schema
.alterTable('test')
.call((builder) =>
.$call((builder) =>
builder.addColumn('abc', 'integer', (col) => col.defaultTo('42'))
)

Expand Down
2 changes: 1 addition & 1 deletion test/node/src/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ for (const dialect of DIALECTS) {
.updateTable('person')
.set({ last_name: 'Barson' })
.returning('first_name')
.if(condition, (qb) => qb.returning('last_name'))
.$if(condition, (qb) => qb.returning('last_name'))

const result = await query.executeTakeFirstOrThrow()

Expand Down
28 changes: 14 additions & 14 deletions test/typings/test-d/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ async function testCall(db: Kysely<Database>) {
const [r1] = await db
.selectFrom('pet as p')
.select('p.species')
.call((qb) => qb.select('name'))
.$call((qb) => qb.select('name'))
.execute()

expectType<{ species: 'dog' | 'cat'; name: string }>(r1)
Expand All @@ -384,15 +384,15 @@ async function testIf(db: Kysely<Database>) {
const [r1] = await db
.selectFrom('pet as p')
.select('p.species')
.if(condition, (qb) => qb.select('name'))
.$if(condition, (qb) => qb.select('name'))
.execute()

expectType<{ species: 'dog' | 'cat'; name?: string }>(r1)

// Conditional returning in delete
const [r2] = await db
.deleteFrom('person')
.if(condition, (qb) => qb.returning('first_name'))
.$if(condition, (qb) => qb.returning('first_name'))
.execute()

expectType<{ first_name?: string }>(r2)
Expand All @@ -401,15 +401,15 @@ async function testIf(db: Kysely<Database>) {
const [r3] = await db
.deleteFrom('person')
.returning('first_name')
.if(condition, (qb) => qb.returning('last_name'))
.$if(condition, (qb) => qb.returning('last_name'))
.execute()

expectType<{ first_name: string; last_name?: string | null }>(r3)

// Conditional where in delete
const [r4] = await db
.deleteFrom('person')
.if(condition, (qb) => qb.where('id', '=', 1))
.$if(condition, (qb) => qb.where('id', '=', 1))
.execute()

expectType<DeleteResult>(r4)
Expand All @@ -418,7 +418,7 @@ async function testIf(db: Kysely<Database>) {
const [r5] = await db
.deleteFrom('person')
.returning('first_name')
.if(condition, (qb) => qb.where('id', '=', 1))
.$if(condition, (qb) => qb.where('id', '=', 1))
.execute()

expectType<{ first_name: string }>(r5)
Expand All @@ -427,7 +427,7 @@ async function testIf(db: Kysely<Database>) {
const [r6] = await db
.updateTable('person')
.set({ last_name: 'Foo' })
.if(condition, (qb) => qb.returning('first_name'))
.$if(condition, (qb) => qb.returning('first_name'))
.execute()

expectType<{ first_name?: string }>(r6)
Expand All @@ -437,7 +437,7 @@ async function testIf(db: Kysely<Database>) {
.updateTable('person')
.set({ last_name: 'Foo' })
.returning('first_name')
.if(condition, (qb) => qb.returning('last_name'))
.$if(condition, (qb) => qb.returning('last_name'))
.execute()

expectType<{ first_name: string; last_name?: string | null }>(r7)
Expand All @@ -446,7 +446,7 @@ async function testIf(db: Kysely<Database>) {
const [r8] = await db
.updateTable('person')
.set({ last_name: 'Foo' })
.if(condition, (qb) => qb.where('id', '=', 1))
.$if(condition, (qb) => qb.where('id', '=', 1))
.execute()

expectType<UpdateResult>(r8)
Expand All @@ -456,7 +456,7 @@ async function testIf(db: Kysely<Database>) {
.updateTable('person')
.set({ last_name: 'Foo' })
.returning('first_name')
.if(condition, (qb) => qb.where('id', '=', 1))
.$if(condition, (qb) => qb.where('id', '=', 1))
.execute()

expectType<{ first_name: string }>(r9)
Expand All @@ -465,7 +465,7 @@ async function testIf(db: Kysely<Database>) {
const [r10] = await db
.insertInto('person')
.values({ first_name: 'Foo', last_name: 'Bar', gender: 'other', age: 0 })
.if(condition, (qb) => qb.returning('first_name'))
.$if(condition, (qb) => qb.returning('first_name'))
.execute()

expectType<{ first_name?: string }>(r10)
Expand All @@ -475,7 +475,7 @@ async function testIf(db: Kysely<Database>) {
.insertInto('person')
.values({ first_name: 'Foo', last_name: 'Bar', gender: 'other', age: 0 })
.returning('first_name')
.if(condition, (qb) => qb.returning('last_name'))
.$if(condition, (qb) => qb.returning('last_name'))
.execute()

expectType<{ first_name: string; last_name?: string | null }>(r11)
Expand All @@ -484,7 +484,7 @@ async function testIf(db: Kysely<Database>) {
const [r12] = await db
.insertInto('person')
.values({ first_name: 'Foo', last_name: 'Bar', gender: 'other', age: 0 })
.if(condition, (qb) => qb.ignore())
.$if(condition, (qb) => qb.ignore())
.execute()

expectType<InsertResult>(r12)
Expand All @@ -494,7 +494,7 @@ async function testIf(db: Kysely<Database>) {
.insertInto('person')
.values({ first_name: 'Foo', last_name: 'Bar', gender: 'other', age: 0 })
.returning('first_name')
.if(condition, (qb) => qb.ignore())
.$if(condition, (qb) => qb.ignore())
.execute()

expectType<{ first_name: string }>(r13)
Expand Down

1 comment on commit 8b1cede

@vercel
Copy link

@vercel vercel bot commented on 8b1cede Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kysely – ./

kysely-kysely-team.vercel.app
kysely-git-master-kysely-team.vercel.app
kysely.dev
www.kysely.dev

Please sign in to comment.