diff --git a/drizzle-orm/src/sql/expressions/conditions.ts b/drizzle-orm/src/sql/expressions/conditions.ts index ba0e21fbc..7ad1355dd 100644 --- a/drizzle-orm/src/sql/expressions/conditions.ts +++ b/drizzle-orm/src/sql/expressions/conditions.ts @@ -526,7 +526,7 @@ export function notBetween( * * @see ilike for a case-insensitive version of this condition */ -export function like(column: Column, value: string | SQLWrapper): SQL { +export function like(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL { return sql`${column} like ${value}`; } @@ -548,7 +548,7 @@ export function like(column: Column, value: string | SQLWrapper): SQL { * @see like for the inverse condition * @see notIlike for a case-insensitive version of this condition */ -export function notLike(column: Column, value: string | SQLWrapper): SQL { +export function notLike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL { return sql`${column} not like ${value}`; } @@ -571,7 +571,7 @@ export function notLike(column: Column, value: string | SQLWrapper): SQL { * * @see like for a case-sensitive version of this condition */ -export function ilike(column: Column, value: string | SQLWrapper): SQL { +export function ilike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL { return sql`${column} ilike ${value}`; } @@ -593,7 +593,7 @@ export function ilike(column: Column, value: string | SQLWrapper): SQL { * @see ilike for the inverse condition * @see notLike for a case-sensitive version of this condition */ -export function notIlike(column: Column, value: string | SQLWrapper): SQL { +export function notIlike(column: Column | SQL.Aliased | SQL, value: string | SQLWrapper): SQL { return sql`${column} not ilike ${value}`; } diff --git a/drizzle-orm/type-tests/mysql/with.ts b/drizzle-orm/type-tests/mysql/with.ts index b4e528191..e6f240489 100644 --- a/drizzle-orm/type-tests/mysql/with.ts +++ b/drizzle-orm/type-tests/mysql/with.ts @@ -1,6 +1,6 @@ import type { Equal } from 'type-tests/utils.ts'; import { Expect } from 'type-tests/utils.ts'; -import { gt, inArray } from '~/expressions.ts'; +import { gt, inArray, like } from '~/expressions.ts'; import { int, mysqlTable, serial, text } from '~/mysql-core/index.ts'; import { sql } from '~/sql/sql.ts'; import { db } from './db.ts'; @@ -77,4 +77,7 @@ const orders = mysqlTable('orders', { generated: string | null; }[], typeof allFromWith> >; + + const regionalSalesWith = db.$with('regional_sales_with').as(db.select().from(regionalSales)); + db.with(regionalSalesWith).select().from(regionalSalesWith).where(like(regionalSalesWith.totalSales, 'abc')); } diff --git a/drizzle-orm/type-tests/pg/with.ts b/drizzle-orm/type-tests/pg/with.ts index d5fcc96ed..288e3b6d0 100644 --- a/drizzle-orm/type-tests/pg/with.ts +++ b/drizzle-orm/type-tests/pg/with.ts @@ -1,6 +1,6 @@ import type { Equal } from 'type-tests/utils.ts'; import { Expect } from 'type-tests/utils.ts'; -import { gt, inArray } from '~/expressions.ts'; +import { gt, inArray, like } from '~/expressions.ts'; import { integer, pgTable, serial, text } from '~/pg-core/index.ts'; import { sql } from '~/sql/sql.ts'; import { db } from './db.ts'; @@ -77,4 +77,7 @@ const orders = pgTable('orders', { generated: string | null; }[], typeof allFromWith> >; + + const regionalSalesWith = db.$with('regional_sales_with').as(db.select().from(regionalSales)); + db.with(regionalSalesWith).select().from(regionalSalesWith).where(like(regionalSalesWith.totalSales, 'abc')); } diff --git a/drizzle-orm/type-tests/sqlite/with.ts b/drizzle-orm/type-tests/sqlite/with.ts index 8b5963eb6..b26e4e7d7 100644 --- a/drizzle-orm/type-tests/sqlite/with.ts +++ b/drizzle-orm/type-tests/sqlite/with.ts @@ -1,6 +1,6 @@ import type { Equal } from 'type-tests/utils.ts'; import { Expect } from 'type-tests/utils.ts'; -import { gt, inArray } from '~/expressions.ts'; +import { gt, inArray, like } from '~/expressions.ts'; import { sql } from '~/sql/sql.ts'; import { integer, sqliteTable, text } from '~/sqlite-core/index.ts'; import { db } from './db.ts'; @@ -78,4 +78,7 @@ const orders = sqliteTable('orders', { generated: string | null; }[], typeof allFromWith> >; + + const regionalSalesWith = db.$with('regional_sales_with').as(db.select().from(regionalSales)); + db.with(regionalSalesWith).select().from(regionalSalesWith).where(like(regionalSalesWith.totalSales, 'abc')); }