From 64a56f98d45b41fb367b27174c33a91c8bcc26b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Koskim=C3=A4ki?= Date: Sat, 23 Mar 2024 17:19:29 +0200 Subject: [PATCH] fix a bunch of untyped sql snippets in API doc examples --- src/expression/expression-builder.ts | 2 +- src/query-builder/function-module.ts | 2 +- src/query-builder/insert-query-builder.ts | 4 ++-- src/query-builder/select-query-builder.ts | 10 +++++----- src/query-builder/update-query-builder.ts | 4 ++-- src/query-builder/where-interface.ts | 2 +- src/raw-builder/sql.ts | 10 +++++----- src/schema/alter-table-add-index-builder.ts | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/expression/expression-builder.ts b/src/expression/expression-builder.ts index a1f6b8434..a5baf7277 100644 --- a/src/expression/expression-builder.ts +++ b/src/expression/expression-builder.ts @@ -404,7 +404,7 @@ export interface ExpressionBuilder { * * ```ts * db.update('pet').set((eb) => ({ - * name: sql`concat(${eb.ref('pet.name')}, ${suffix})` + * name: sql`concat(${eb.ref('pet.name')}, ${suffix})` * })) * ``` * diff --git a/src/query-builder/function-module.ts b/src/query-builder/function-module.ts index 0c1dfa6e6..dda74d9f1 100644 --- a/src/query-builder/function-module.ts +++ b/src/query-builder/function-module.ts @@ -124,7 +124,7 @@ export interface FunctionModule { * ```ts * db.selectFrom('person') * .selectAll('person') - * .where(sql`upper(first_name)`, '=', 'JENNIFER') + * .where(sql`upper(first_name)`, '=', 'JENNIFER') * ``` */ = ReferenceExpression>( diff --git a/src/query-builder/insert-query-builder.ts b/src/query-builder/insert-query-builder.ts index 09b19b202..f1c40130b 100644 --- a/src/query-builder/insert-query-builder.ts +++ b/src/query-builder/insert-query-builder.ts @@ -193,7 +193,7 @@ export class InsertQueryBuilder * .insertInto('person') * .values(({ ref, selectFrom, fn }) => ({ * first_name: 'Jennifer', - * last_name: sql`concat(${ani}, ${ston})`, + * last_name: sql`>concat(${ani}, ${ston})`, * middle_name: ref('first_name'), * age: selectFrom('person') * .select(fn.avg('age').as('avg_age')), @@ -496,7 +496,7 @@ export class InsertQueryBuilder * species: 'cat', * }) * .onConflict((oc) => oc - * .expression(sql`lower(name)`) + * .expression(sql`lower(name)`) * .doUpdateSet({ species: 'hamster' }) * ) * .execute() diff --git a/src/query-builder/select-query-builder.ts b/src/query-builder/select-query-builder.ts index fe28f13c0..dcdbe5c71 100644 --- a/src/query-builder/select-query-builder.ts +++ b/src/query-builder/select-query-builder.ts @@ -912,7 +912,7 @@ export interface SelectQueryBuilder * .limit(1) * ) * .orderBy( - * sql`concat(first_name, last_name)` + * sql`concat(first_name, last_name)` * ) * .execute() * ``` @@ -981,7 +981,7 @@ export interface SelectQueryBuilder * .selectFrom('person') * .select([ * 'first_name', - * sql`max(id)`.as('max_id') + * sql`max(id)`.as('max_id') * ]) * .groupBy('first_name') * .execute() @@ -1005,7 +1005,7 @@ export interface SelectQueryBuilder * .select([ * 'first_name', * 'last_name', - * sql`max(id)`.as('max_id') + * sql`max(id)`.as('max_id') * ]) * .groupBy([ * 'first_name', @@ -1033,10 +1033,10 @@ export interface SelectQueryBuilder * .select([ * 'first_name', * 'last_name', - * sql`max(id)`.as('max_id') + * sql`max(id)`.as('max_id') * ]) * .groupBy([ - * sql`concat(first_name, last_name)`, + * sql`concat(first_name, last_name)`, * (qb) => qb.selectFrom('pet').select('id').limit(1) * ]) * .execute() diff --git a/src/query-builder/update-query-builder.ts b/src/query-builder/update-query-builder.ts index 31333ca58..937918b8d 100644 --- a/src/query-builder/update-query-builder.ts +++ b/src/query-builder/update-query-builder.ts @@ -561,7 +561,7 @@ export class UpdateQueryBuilder * .set('first_name', 'Foo') * // As always, both arguments can be arbitrary expressions or * // callbacks that give you access to an expression builder: - * .set(sql`address['postalCode']`, (eb) => eb.val('61710)) + * .set(sql`address['postalCode']`, (eb) => eb.val('61710)) * .where('id', '=', '1') * .executeTakeFirst() * ``` @@ -602,7 +602,7 @@ export class UpdateQueryBuilder * first_name: selectFrom('person').select('first_name').limit(1), * middle_name: ref('first_name'), * age: eb('age', '+', 1), - * last_name: sql`${'Ani'} || ${'ston'}`, + * last_name: sql`${'Ani'} || ${'ston'}`, * })) * .where('id', '=', 1) * .executeTakeFirst() diff --git a/src/query-builder/where-interface.ts b/src/query-builder/where-interface.ts index de56d210c..2564a3194 100644 --- a/src/query-builder/where-interface.ts +++ b/src/query-builder/where-interface.ts @@ -270,7 +270,7 @@ export interface WhereInterface { * .selectFrom('person') * .selectAll() * .where( - * sql`coalesce(first_name, last_name)`, + * sql`coalesce(first_name, last_name)`, * 'like', * '%' + name + '%', * ) diff --git a/src/raw-builder/sql.ts b/src/raw-builder/sql.ts index 11994a755..5ed887fd5 100644 --- a/src/raw-builder/sql.ts +++ b/src/raw-builder/sql.ts @@ -43,12 +43,12 @@ export interface Sql { * // method to give it an alias. * sql`concat(first_name, ' ', last_name)`.as('full_name') * ) - * .where(sql`birthdate between ${date1} and ${date2}`) + * .where(sql`birthdate between ${date1} and ${date2}`) * // Here we assume we have list of nicknames for the person * // (a list of strings) and we use the PostgreSQL `@>` operator * // to test if all of them are valid nicknames for the user. - * .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`) - * .orderBy(sql`concat(first_name, ' ', last_name)`) + * .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`) + * .orderBy(sql`concat(first_name, ' ', last_name)`) * .execute() * ``` * @@ -73,7 +73,7 @@ export interface Sql { * * ```ts * const petName = db.selectFrom('pet').select('name').limit(1) - * const fullName = sql`concat(first_name, ' ', last_name)` + * const fullName = sql`concat(first_name, ' ', last_name)` * * sql` * select ${fullName} as full_name, ${petName} as pet_name @@ -323,7 +323,7 @@ export interface Sql { * return db * .selectFrom('person') * .selectAll() - * .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`) + * .where('nicknames', '@>', sql`ARRAY[${sql.join(nicknames)}]`) * .execute() * } * ``` diff --git a/src/schema/alter-table-add-index-builder.ts b/src/schema/alter-table-add-index-builder.ts index 18d8ef911..6110883a0 100644 --- a/src/schema/alter-table-add-index-builder.ts +++ b/src/schema/alter-table-add-index-builder.ts @@ -121,7 +121,7 @@ export class AlterTableAddIndexBuilder * await db.schema * .alterTable('person') * .addIndex('person_first_name_index') - * .expression(sql`(first_name < 'Sami')`) + * .expression(sql`(first_name < 'Sami')`) * .execute() * ``` *