From e348b8cdead27ead9c5728b62bca36a6c6bc2701 Mon Sep 17 00:00:00 2001 From: Mario564 Date: Tue, 17 Sep 2024 10:14:13 -0700 Subject: [PATCH 1/8] Implement limit and order by in MySQL --- drizzle-orm/src/mysql-core/dialect.ts | 42 ++++++++++++------- .../src/mysql-core/query-builders/delete.ts | 39 ++++++++++++++++- .../src/mysql-core/query-builders/update.ts | 40 +++++++++++++++++- drizzle-orm/type-tests/mysql/delete.ts | 4 ++ drizzle-orm/type-tests/mysql/update.ts | 4 ++ integration-tests/tests/mysql/mysql-common.ts | 19 +++++++++ 6 files changed, 129 insertions(+), 19 deletions(-) diff --git a/drizzle-orm/src/mysql-core/dialect.ts b/drizzle-orm/src/mysql-core/dialect.ts index 4a72d9c5f..0e3fe3d23 100644 --- a/drizzle-orm/src/mysql-core/dialect.ts +++ b/drizzle-orm/src/mysql-core/dialect.ts @@ -17,7 +17,7 @@ import { type TablesRelationalConfig, } from '~/relations.ts'; import { Param, SQL, sql, View } from '~/sql/sql.ts'; -import type { Name, QueryWithTypings, SQLChunk } from '~/sql/sql.ts'; +import type { Name, Placeholder, QueryWithTypings, SQLChunk } from '~/sql/sql.ts'; import { Subquery } from '~/subquery.ts'; import { getTableName, getTableUniqueName, Table } from '~/table.ts'; import { orderSelectedFields, type UpdateSet } from '~/utils.ts'; @@ -100,7 +100,7 @@ export class MySqlDialect { return sql.join(withSqlChunks); } - buildDeleteQuery({ table, where, returning, withList }: MySqlDeleteConfig): SQL { + buildDeleteQuery({ table, where, returning, withList, limit, orderBy }: MySqlDeleteConfig): SQL { const withSql = this.buildWithCTE(withList); const returningSql = returning @@ -109,7 +109,11 @@ export class MySqlDialect { const whereSql = where ? sql` where ${where}` : undefined; - return sql`${withSql}delete from ${table}${whereSql}${returningSql}`; + const orderBySql = this.buildOrderBy(orderBy); + + const limitSql = this.buildLimit(limit); + + return sql`${withSql}delete from ${table}${whereSql}${orderBySql}${limitSql}${returningSql}`; } buildUpdateSet(table: MySqlTable, set: UpdateSet): SQL { @@ -133,7 +137,7 @@ export class MySqlDialect { })); } - buildUpdateQuery({ table, set, where, returning, withList }: MySqlUpdateConfig): SQL { + buildUpdateQuery({ table, set, where, returning, withList, limit, orderBy }: MySqlUpdateConfig): SQL { const withSql = this.buildWithCTE(withList); const setSql = this.buildUpdateSet(table, set); @@ -144,7 +148,11 @@ export class MySqlDialect { const whereSql = where ? sql` where ${where}` : undefined; - return sql`${withSql}update ${table} set ${setSql}${whereSql}${returningSql}`; + const orderBySql = this.buildOrderBy(orderBy); + + const limitSql = this.buildLimit(limit); + + return sql`${withSql}update ${table} set ${setSql}${whereSql}${orderBySql}${limitSql}${returningSql}`; } /** @@ -209,6 +217,16 @@ export class MySqlDialect { return sql.join(chunks); } + private buildLimit(limit: number | Placeholder | undefined): SQL | undefined { + return typeof limit === 'object' || (typeof limit === 'number' && limit >= 0) + ? sql` limit ${limit}` + : undefined + } + + private buildOrderBy(orderBy: (MySqlColumn | SQL | SQL.Aliased)[] | undefined): SQL | undefined { + return orderBy ? sql` order by ${sql.join(orderBy, sql`, `)}` : undefined + } + buildSelectQuery( { withList, @@ -316,19 +334,11 @@ export class MySqlDialect { const havingSql = having ? sql` having ${having}` : undefined; - let orderBySql; - if (orderBy && orderBy.length > 0) { - orderBySql = sql` order by ${sql.join(orderBy, sql`, `)}`; - } + const orderBySql = this.buildOrderBy(orderBy); - let groupBySql; - if (groupBy && groupBy.length > 0) { - groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`; - } + const groupBySql = groupBy && groupBy.length > 0 ? sql` group by ${sql.join(groupBy, sql`, `)}` : undefined; - const limitSql = typeof limit === 'object' || (typeof limit === 'number' && limit >= 0) - ? sql` limit ${limit}` - : undefined; + const limitSql = this.buildLimit(limit); const offsetSql = offset ? sql` offset ${offset}` : undefined; diff --git a/drizzle-orm/src/mysql-core/query-builders/delete.ts b/drizzle-orm/src/mysql-core/query-builders/delete.ts index e9a48da8e..7b5d22624 100644 --- a/drizzle-orm/src/mysql-core/query-builders/delete.ts +++ b/drizzle-orm/src/mysql-core/query-builders/delete.ts @@ -11,9 +11,13 @@ import type { } from '~/mysql-core/session.ts'; import type { MySqlTable } from '~/mysql-core/table.ts'; import { QueryPromise } from '~/query-promise.ts'; -import type { Query, SQL, SQLWrapper } from '~/sql/sql.ts'; +import { Table } from '~/table.ts'; +import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { Subquery } from '~/subquery.ts'; import type { SelectedFieldsOrdered } from './select.types.ts'; +import type { MySqlColumn } from '../columns/common.ts'; +import type { ValueOrArray } from '~/utils.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; export type MySqlDeleteWithout< T extends AnyMySqlDeleteBase, @@ -39,6 +43,8 @@ export type MySqlDelete< export interface MySqlDeleteConfig { where?: SQL | undefined; + limit?: number | Placeholder; + orderBy?: (MySqlColumn | SQL | SQL.Aliased)[]; table: MySqlTable; returning?: SelectedFieldsOrdered; withList?: Subquery[]; @@ -134,6 +140,37 @@ export class MySqlDeleteBase< return this as any; } + orderBy( + builder: (updateTable: TTable) => ValueOrArray, + ): MySqlDeleteWithout; + orderBy(...columns: (MySqlColumn | SQL | SQL.Aliased)[]): MySqlDeleteWithout; + orderBy( + ...columns: + | [(updateTable: TTable) => ValueOrArray] + | (MySqlColumn | SQL | SQL.Aliased)[] + ): MySqlDeleteWithout { + if (typeof columns[0] === 'function') { + const orderBy = columns[0]( + new Proxy( + this.config.table[Table.Symbol.Columns], + new SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }), + ) as any, + ); + + const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy]; + this.config.orderBy = orderByArray; + } else { + const orderByArray = columns as (MySqlColumn | SQL | SQL.Aliased)[]; + this.config.orderBy = orderByArray; + } + return this as any; + } + + limit(limit: number | Placeholder): MySqlDeleteWithout { + this.config.limit = limit; + return this as any; + } + /** @internal */ getSQL(): SQL { return this.dialect.buildDeleteQuery(this.config); diff --git a/drizzle-orm/src/mysql-core/query-builders/update.ts b/drizzle-orm/src/mysql-core/query-builders/update.ts index 7884599cf..8a86c748b 100644 --- a/drizzle-orm/src/mysql-core/query-builders/update.ts +++ b/drizzle-orm/src/mysql-core/query-builders/update.ts @@ -12,13 +12,18 @@ import type { } from '~/mysql-core/session.ts'; import type { MySqlTable } from '~/mysql-core/table.ts'; import { QueryPromise } from '~/query-promise.ts'; -import type { Query, SQL, SQLWrapper } from '~/sql/sql.ts'; +import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { Subquery } from '~/subquery.ts'; -import { mapUpdateSet, type UpdateSet } from '~/utils.ts'; +import { mapUpdateSet, type ValueOrArray, type UpdateSet } from '~/utils.ts'; import type { SelectedFieldsOrdered } from './select.types.ts'; +import type { MySqlColumn } from '../columns/common.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; +import { Table } from '~/table.ts'; export interface MySqlUpdateConfig { where?: SQL | undefined; + limit?: number | Placeholder; + orderBy?: (MySqlColumn | SQL | SQL.Aliased)[]; set: UpdateSet; table: MySqlTable; returning?: SelectedFieldsOrdered; @@ -173,6 +178,37 @@ export class MySqlUpdateBase< return this as any; } + orderBy( + builder: (updateTable: TTable) => ValueOrArray, + ): MySqlUpdateWithout; + orderBy(...columns: (MySqlColumn | SQL | SQL.Aliased)[]): MySqlUpdateWithout; + orderBy( + ...columns: + | [(updateTable: TTable) => ValueOrArray] + | (MySqlColumn | SQL | SQL.Aliased)[] + ): MySqlUpdateWithout { + if (typeof columns[0] === 'function') { + const orderBy = columns[0]( + new Proxy( + this.config.table[Table.Symbol.Columns], + new SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }), + ) as any, + ); + + const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy]; + this.config.orderBy = orderByArray; + } else { + const orderByArray = columns as (MySqlColumn | SQL | SQL.Aliased)[]; + this.config.orderBy = orderByArray; + } + return this as any; + } + + limit(limit: number | Placeholder): MySqlUpdateWithout { + this.config.limit = limit; + return this as any; + } + /** @internal */ getSQL(): SQL { return this.dialect.buildUpdateQuery(this.config); diff --git a/drizzle-orm/type-tests/mysql/delete.ts b/drizzle-orm/type-tests/mysql/delete.ts index c3e5afbb2..84c827ba8 100644 --- a/drizzle-orm/type-tests/mysql/delete.ts +++ b/drizzle-orm/type-tests/mysql/delete.ts @@ -59,3 +59,7 @@ Expect>; .where(sql``) .where(sql``); } + +{ + db.delete(users).where(sql``).limit(1).orderBy(sql``); +} diff --git a/drizzle-orm/type-tests/mysql/update.ts b/drizzle-orm/type-tests/mysql/update.ts index dc6967f44..abb127b5d 100644 --- a/drizzle-orm/type-tests/mysql/update.ts +++ b/drizzle-orm/type-tests/mysql/update.ts @@ -24,3 +24,7 @@ import { users } from './tables.ts'; // @ts-expect-error method was already called .where(sql``); } + +{ + db.update(users).set({}).where(sql``).limit(1).orderBy(sql``); +} diff --git a/integration-tests/tests/mysql/mysql-common.ts b/integration-tests/tests/mysql/mysql-common.ts index 8a2fb768b..cdee0a1d3 100644 --- a/integration-tests/tests/mysql/mysql-common.ts +++ b/integration-tests/tests/mysql/mysql-common.ts @@ -3809,5 +3809,24 @@ export function tests(driver?: string) { expect(users.length).toBeGreaterThan(0); }); + + test('update with limit and order by', async (ctx) => { + const { db } = ctx.mysql; + + await db.insert(usersTable).values([ + { name: 'Barry', verified: false }, + { name: 'Alan', verified: false }, + { name: 'Carl', verified: false }, + ]); + + await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); + + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy(asc(usersTable.name)); + expect(result).toStrictEqual([ + { name: 'Alan', verified: true }, + { name: 'Barry', verified: true }, + { name: 'Carl', verified: false }, + ]); + }); }); } From 004c8eb566f3ec4d6ba9b92c39a6d328de694ac4 Mon Sep 17 00:00:00 2001 From: Mario564 Date: Tue, 17 Sep 2024 10:34:13 -0700 Subject: [PATCH 2/8] Add limit and order by to update and delete in SQLite --- drizzle-orm/src/mysql-core/dialect.ts | 2 +- .../src/mysql-core/query-builders/delete.ts | 4 +- drizzle-orm/src/sqlite-core/dialect.ts | 57 ++++++++++++------- .../src/sqlite-core/query-builders/delete.ts | 39 ++++++++++++- .../src/sqlite-core/query-builders/update.ts | 39 ++++++++++++- drizzle-orm/type-tests/sqlite/delete.ts | 4 ++ drizzle-orm/type-tests/sqlite/update.ts | 4 ++ .../tests/sqlite/sqlite-common.ts | 19 +++++++ 8 files changed, 141 insertions(+), 27 deletions(-) diff --git a/drizzle-orm/src/mysql-core/dialect.ts b/drizzle-orm/src/mysql-core/dialect.ts index 0e3fe3d23..91b0a93fd 100644 --- a/drizzle-orm/src/mysql-core/dialect.ts +++ b/drizzle-orm/src/mysql-core/dialect.ts @@ -224,7 +224,7 @@ export class MySqlDialect { } private buildOrderBy(orderBy: (MySqlColumn | SQL | SQL.Aliased)[] | undefined): SQL | undefined { - return orderBy ? sql` order by ${sql.join(orderBy, sql`, `)}` : undefined + return orderBy && orderBy.length > 0 ? sql` order by ${sql.join(orderBy, sql`, `)}` : undefined } buildSelectQuery( diff --git a/drizzle-orm/src/mysql-core/query-builders/delete.ts b/drizzle-orm/src/mysql-core/query-builders/delete.ts index 7b5d22624..fe9c5ac8d 100644 --- a/drizzle-orm/src/mysql-core/query-builders/delete.ts +++ b/drizzle-orm/src/mysql-core/query-builders/delete.ts @@ -141,12 +141,12 @@ export class MySqlDeleteBase< } orderBy( - builder: (updateTable: TTable) => ValueOrArray, + builder: (deleteTable: TTable) => ValueOrArray, ): MySqlDeleteWithout; orderBy(...columns: (MySqlColumn | SQL | SQL.Aliased)[]): MySqlDeleteWithout; orderBy( ...columns: - | [(updateTable: TTable) => ValueOrArray] + | [(deleteTable: TTable) => ValueOrArray] | (MySqlColumn | SQL | SQL.Aliased)[] ): MySqlDeleteWithout { if (typeof columns[0] === 'function') { diff --git a/drizzle-orm/src/sqlite-core/dialect.ts b/drizzle-orm/src/sqlite-core/dialect.ts index 645e15592..b7638b5e9 100644 --- a/drizzle-orm/src/sqlite-core/dialect.ts +++ b/drizzle-orm/src/sqlite-core/dialect.ts @@ -16,7 +16,7 @@ import { type TableRelationalConfig, type TablesRelationalConfig, } from '~/relations.ts'; -import type { Name } from '~/sql/index.ts'; +import type { Name, Placeholder } from '~/sql/index.ts'; import { and, eq } from '~/sql/index.ts'; import { Param, type QueryWithTypings, SQL, sql, type SQLChunk } from '~/sql/sql.ts'; import { SQLiteColumn } from '~/sqlite-core/columns/index.ts'; @@ -63,7 +63,7 @@ export abstract class SQLiteDialect { return sql.join(withSqlChunks); } - buildDeleteQuery({ table, where, returning, withList }: SQLiteDeleteConfig): SQL { + buildDeleteQuery({ table, where, returning, withList, limit, orderBy }: SQLiteDeleteConfig): SQL { const withSql = this.buildWithCTE(withList); const returningSql = returning @@ -72,7 +72,11 @@ export abstract class SQLiteDialect { const whereSql = where ? sql` where ${where}` : undefined; - return sql`${withSql}delete from ${table}${whereSql}${returningSql}`; + const orderBySql = this.buildOrderBy(orderBy); + + const limitSql = this.buildLimit(limit); + + return sql`${withSql}delete from ${table}${whereSql}${returningSql}${orderBySql}${limitSql}`; } buildUpdateSet(table: SQLiteTable, set: UpdateSet): SQL { @@ -96,7 +100,7 @@ export abstract class SQLiteDialect { })); } - buildUpdateQuery({ table, set, where, returning, withList }: SQLiteUpdateConfig): SQL { + buildUpdateQuery({ table, set, where, returning, withList, limit, orderBy }: SQLiteUpdateConfig): SQL { const withSql = this.buildWithCTE(withList); const setSql = this.buildUpdateSet(table, set); @@ -107,7 +111,11 @@ export abstract class SQLiteDialect { const whereSql = where ? sql` where ${where}` : undefined; - return sql`${withSql}update ${table} set ${setSql}${whereSql}${returningSql}`; + const orderBySql = this.buildOrderBy(orderBy); + + const limitSql = this.buildLimit(limit); + + return sql`${withSql}update ${table} set ${setSql}${whereSql}${returningSql}${orderBySql}${limitSql}`; } /** @@ -174,6 +182,28 @@ export abstract class SQLiteDialect { return sql.join(chunks); } + private buildLimit(limit: number | Placeholder | undefined): SQL | undefined { + return typeof limit === 'object' || (typeof limit === 'number' && limit >= 0) + ? sql` limit ${limit}` + : undefined + } + + private buildOrderBy(orderBy: (SQLiteColumn | SQL | SQL.Aliased)[] | undefined): SQL | undefined { + const orderByList: (SQLiteColumn | SQL | SQL.Aliased)[] = []; + + if (orderBy) { + for (const [index, orderByValue] of orderBy.entries()) { + orderByList.push(orderByValue); + + if (index < orderBy.length - 1) { + orderByList.push(sql`, `); + } + } + } + + return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : undefined + } + buildSelectQuery( { withList, @@ -269,17 +299,6 @@ export abstract class SQLiteDialect { const havingSql = having ? sql` having ${having}` : undefined; - const orderByList: (SQLiteColumn | SQL | SQL.Aliased)[] = []; - if (orderBy) { - for (const [index, orderByValue] of orderBy.entries()) { - orderByList.push(orderByValue); - - if (index < orderBy.length - 1) { - orderByList.push(sql`, `); - } - } - } - const groupByList: (SQL | AnyColumn | SQL.Aliased)[] = []; if (groupBy) { for (const [index, groupByValue] of groupBy.entries()) { @@ -293,11 +312,9 @@ export abstract class SQLiteDialect { const groupBySql = groupByList.length > 0 ? sql` group by ${sql.join(groupByList)}` : undefined; - const orderBySql = orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : undefined; + const orderBySql = this.buildOrderBy(orderBy); - const limitSql = typeof limit === 'object' || (typeof limit === 'number' && limit >= 0) - ? sql` limit ${limit}` - : undefined; + const limitSql = this.buildLimit(limit); const offsetSql = offset ? sql` offset ${offset}` : undefined; diff --git a/drizzle-orm/src/sqlite-core/query-builders/delete.ts b/drizzle-orm/src/sqlite-core/query-builders/delete.ts index 1a028c09a..cf0b6bd7a 100644 --- a/drizzle-orm/src/sqlite-core/query-builders/delete.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/delete.ts @@ -2,14 +2,16 @@ import { entityKind } from '~/entity.ts'; import type { SelectResultFields } from '~/query-builders/select.types.ts'; import { QueryPromise } from '~/query-promise.ts'; import type { RunnableQuery } from '~/runnable-query.ts'; -import type { Query, SQL, SQLWrapper } from '~/sql/sql.ts'; +import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { SQLiteDialect } from '~/sqlite-core/dialect.ts'; import type { SQLitePreparedQuery, SQLiteSession } from '~/sqlite-core/session.ts'; import { SQLiteTable } from '~/sqlite-core/table.ts'; import type { Subquery } from '~/subquery.ts'; -import { type DrizzleTypeError, orderSelectedFields } from '~/utils.ts'; +import { type DrizzleTypeError, orderSelectedFields, type ValueOrArray } from '~/utils.ts'; import type { SQLiteColumn } from '../columns/common.ts'; import type { SelectedFieldsFlat, SelectedFieldsOrdered } from './select.types.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; +import { Table } from '~/table.ts'; export type SQLiteDeleteWithout< T extends AnySQLiteDeleteBase, @@ -37,6 +39,8 @@ export type SQLiteDelete< export interface SQLiteDeleteConfig { where?: SQL | undefined; + limit?: number | Placeholder; + orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[]; table: SQLiteTable; returning?: SelectedFieldsOrdered; withList?: Subquery[]; @@ -185,6 +189,37 @@ export class SQLiteDeleteBase< return this as any; } + orderBy( + builder: (deleteTable: TTable) => ValueOrArray, + ): SQLiteDeleteWithout; + orderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteDeleteWithout; + orderBy( + ...columns: + | [(deleteTable: TTable) => ValueOrArray] + | (SQLiteColumn | SQL | SQL.Aliased)[] + ): SQLiteDeleteWithout { + if (typeof columns[0] === 'function') { + const orderBy = columns[0]( + new Proxy( + this.config.table[Table.Symbol.Columns], + new SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }), + ) as any, + ); + + const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy]; + this.config.orderBy = orderByArray; + } else { + const orderByArray = columns as (SQLiteColumn | SQL | SQL.Aliased)[]; + this.config.orderBy = orderByArray; + } + return this as any; + } + + limit(limit: number | Placeholder): SQLiteDeleteWithout { + this.config.limit = limit; + return this as any; + } + /** * Adds a `returning` clause to the query. * diff --git a/drizzle-orm/src/sqlite-core/query-builders/update.ts b/drizzle-orm/src/sqlite-core/query-builders/update.ts index 0238b748f..9d4543f26 100644 --- a/drizzle-orm/src/sqlite-core/query-builders/update.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/update.ts @@ -3,17 +3,21 @@ import { entityKind } from '~/entity.ts'; import type { SelectResultFields } from '~/query-builders/select.types.ts'; import { QueryPromise } from '~/query-promise.ts'; import type { RunnableQuery } from '~/runnable-query.ts'; -import type { Query, SQL, SQLWrapper } from '~/sql/sql.ts'; +import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { SQLiteDialect } from '~/sqlite-core/dialect.ts'; import type { SQLitePreparedQuery, SQLiteSession } from '~/sqlite-core/session.ts'; import { SQLiteTable } from '~/sqlite-core/table.ts'; import type { Subquery } from '~/subquery.ts'; -import { type DrizzleTypeError, mapUpdateSet, orderSelectedFields, type UpdateSet } from '~/utils.ts'; +import { type DrizzleTypeError, mapUpdateSet, orderSelectedFields, type UpdateSet, type ValueOrArray } from '~/utils.ts'; import type { SQLiteColumn } from '../columns/common.ts'; import type { SelectedFields, SelectedFieldsOrdered } from './select.types.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; +import { Table } from '~/table.ts'; export interface SQLiteUpdateConfig { where?: SQL | undefined; + limit?: number | Placeholder; + orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[]; set: UpdateSet; table: SQLiteTable; returning?: SelectedFieldsOrdered; @@ -223,6 +227,37 @@ export class SQLiteUpdateBase< return this as any; } + orderBy( + builder: (updateTable: TTable) => ValueOrArray, + ): SQLiteUpdateWithout; + orderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteUpdateWithout; + orderBy( + ...columns: + | [(updateTable: TTable) => ValueOrArray] + | (SQLiteColumn | SQL | SQL.Aliased)[] + ): SQLiteUpdateWithout { + if (typeof columns[0] === 'function') { + const orderBy = columns[0]( + new Proxy( + this.config.table[Table.Symbol.Columns], + new SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }), + ) as any, + ); + + const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy]; + this.config.orderBy = orderByArray; + } else { + const orderByArray = columns as (SQLiteColumn | SQL | SQL.Aliased)[]; + this.config.orderBy = orderByArray; + } + return this as any; + } + + limit(limit: number | Placeholder): SQLiteUpdateWithout { + this.config.limit = limit; + return this as any; + } + /** * Adds a `returning` clause to the query. * diff --git a/drizzle-orm/type-tests/sqlite/delete.ts b/drizzle-orm/type-tests/sqlite/delete.ts index fcc754740..cc6539d98 100644 --- a/drizzle-orm/type-tests/sqlite/delete.ts +++ b/drizzle-orm/type-tests/sqlite/delete.ts @@ -152,3 +152,7 @@ Expect>; // @ts-expect-error method was already called .returning(); } + +{ + db.delete(users).where(sql``).limit(1).orderBy(sql``); +} \ No newline at end of file diff --git a/drizzle-orm/type-tests/sqlite/update.ts b/drizzle-orm/type-tests/sqlite/update.ts index aa1f8051f..ab60b5d61 100644 --- a/drizzle-orm/type-tests/sqlite/update.ts +++ b/drizzle-orm/type-tests/sqlite/update.ts @@ -133,3 +133,7 @@ Expect>; // @ts-expect-error method was already called .where(sql``); } + +{ + db.update(users).set({}).where(sql``).limit(1).orderBy(sql``); +} \ No newline at end of file diff --git a/integration-tests/tests/sqlite/sqlite-common.ts b/integration-tests/tests/sqlite/sqlite-common.ts index e8ddb86e6..2de18bd8f 100644 --- a/integration-tests/tests/sqlite/sqlite-common.ts +++ b/integration-tests/tests/sqlite/sqlite-common.ts @@ -2887,6 +2887,25 @@ export function tests() { { count: 3 }, ]); }); + + test('update with limit and order by', async (ctx) => { + const { db } = ctx.sqlite; + + await db.insert(usersTable).values([ + { name: 'Barry', verified: false }, + { name: 'Alan', verified: false }, + { name: 'Carl', verified: false }, + ]); + + await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); + + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy(asc(usersTable.name)); + expect(result).toStrictEqual([ + { name: 'Alan', verified: true }, + { name: 'Barry', verified: true }, + { name: 'Carl', verified: false }, + ]); + }); }); test('table configs: unique third param', () => { From 82b91cff760afabdfe750020cee4e319fd67335f Mon Sep 17 00:00:00 2001 From: Mario564 Date: Tue, 17 Sep 2024 10:38:23 -0700 Subject: [PATCH 3/8] Format --- drizzle-orm/src/mysql-core/dialect.ts | 4 ++-- drizzle-orm/src/mysql-core/query-builders/delete.ts | 8 ++++---- drizzle-orm/src/mysql-core/query-builders/update.ts | 8 ++++---- drizzle-orm/src/sqlite-core/dialect.ts | 6 +++--- drizzle-orm/src/sqlite-core/query-builders/delete.ts | 4 ++-- drizzle-orm/src/sqlite-core/query-builders/update.ts | 12 +++++++++--- drizzle-orm/type-tests/sqlite/delete.ts | 2 +- drizzle-orm/type-tests/sqlite/update.ts | 2 +- integration-tests/tests/mysql/mysql-common.ts | 4 +++- integration-tests/tests/sqlite/sqlite-common.ts | 10 ++++++---- 10 files changed, 35 insertions(+), 25 deletions(-) diff --git a/drizzle-orm/src/mysql-core/dialect.ts b/drizzle-orm/src/mysql-core/dialect.ts index 91b0a93fd..4df694b77 100644 --- a/drizzle-orm/src/mysql-core/dialect.ts +++ b/drizzle-orm/src/mysql-core/dialect.ts @@ -220,11 +220,11 @@ export class MySqlDialect { private buildLimit(limit: number | Placeholder | undefined): SQL | undefined { return typeof limit === 'object' || (typeof limit === 'number' && limit >= 0) ? sql` limit ${limit}` - : undefined + : undefined; } private buildOrderBy(orderBy: (MySqlColumn | SQL | SQL.Aliased)[] | undefined): SQL | undefined { - return orderBy && orderBy.length > 0 ? sql` order by ${sql.join(orderBy, sql`, `)}` : undefined + return orderBy && orderBy.length > 0 ? sql` order by ${sql.join(orderBy, sql`, `)}` : undefined; } buildSelectQuery( diff --git a/drizzle-orm/src/mysql-core/query-builders/delete.ts b/drizzle-orm/src/mysql-core/query-builders/delete.ts index fe9c5ac8d..66ea5d2f4 100644 --- a/drizzle-orm/src/mysql-core/query-builders/delete.ts +++ b/drizzle-orm/src/mysql-core/query-builders/delete.ts @@ -11,13 +11,13 @@ import type { } from '~/mysql-core/session.ts'; import type { MySqlTable } from '~/mysql-core/table.ts'; import { QueryPromise } from '~/query-promise.ts'; -import { Table } from '~/table.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { Subquery } from '~/subquery.ts'; -import type { SelectedFieldsOrdered } from './select.types.ts'; -import type { MySqlColumn } from '../columns/common.ts'; +import { Table } from '~/table.ts'; import type { ValueOrArray } from '~/utils.ts'; -import { SelectionProxyHandler } from '~/selection-proxy.ts'; +import type { MySqlColumn } from '../columns/common.ts'; +import type { SelectedFieldsOrdered } from './select.types.ts'; export type MySqlDeleteWithout< T extends AnyMySqlDeleteBase, diff --git a/drizzle-orm/src/mysql-core/query-builders/update.ts b/drizzle-orm/src/mysql-core/query-builders/update.ts index 8a86c748b..1cc1f43ec 100644 --- a/drizzle-orm/src/mysql-core/query-builders/update.ts +++ b/drizzle-orm/src/mysql-core/query-builders/update.ts @@ -12,13 +12,13 @@ import type { } from '~/mysql-core/session.ts'; import type { MySqlTable } from '~/mysql-core/table.ts'; import { QueryPromise } from '~/query-promise.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { Subquery } from '~/subquery.ts'; -import { mapUpdateSet, type ValueOrArray, type UpdateSet } from '~/utils.ts'; -import type { SelectedFieldsOrdered } from './select.types.ts'; -import type { MySqlColumn } from '../columns/common.ts'; -import { SelectionProxyHandler } from '~/selection-proxy.ts'; import { Table } from '~/table.ts'; +import { mapUpdateSet, type UpdateSet, type ValueOrArray } from '~/utils.ts'; +import type { MySqlColumn } from '../columns/common.ts'; +import type { SelectedFieldsOrdered } from './select.types.ts'; export interface MySqlUpdateConfig { where?: SQL | undefined; diff --git a/drizzle-orm/src/sqlite-core/dialect.ts b/drizzle-orm/src/sqlite-core/dialect.ts index b7638b5e9..5e2162975 100644 --- a/drizzle-orm/src/sqlite-core/dialect.ts +++ b/drizzle-orm/src/sqlite-core/dialect.ts @@ -185,7 +185,7 @@ export abstract class SQLiteDialect { private buildLimit(limit: number | Placeholder | undefined): SQL | undefined { return typeof limit === 'object' || (typeof limit === 'number' && limit >= 0) ? sql` limit ${limit}` - : undefined + : undefined; } private buildOrderBy(orderBy: (SQLiteColumn | SQL | SQL.Aliased)[] | undefined): SQL | undefined { @@ -200,8 +200,8 @@ export abstract class SQLiteDialect { } } } - - return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : undefined + + return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : undefined; } buildSelectQuery( diff --git a/drizzle-orm/src/sqlite-core/query-builders/delete.ts b/drizzle-orm/src/sqlite-core/query-builders/delete.ts index cf0b6bd7a..b89d22c3f 100644 --- a/drizzle-orm/src/sqlite-core/query-builders/delete.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/delete.ts @@ -2,16 +2,16 @@ import { entityKind } from '~/entity.ts'; import type { SelectResultFields } from '~/query-builders/select.types.ts'; import { QueryPromise } from '~/query-promise.ts'; import type { RunnableQuery } from '~/runnable-query.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { SQLiteDialect } from '~/sqlite-core/dialect.ts'; import type { SQLitePreparedQuery, SQLiteSession } from '~/sqlite-core/session.ts'; import { SQLiteTable } from '~/sqlite-core/table.ts'; import type { Subquery } from '~/subquery.ts'; +import { Table } from '~/table.ts'; import { type DrizzleTypeError, orderSelectedFields, type ValueOrArray } from '~/utils.ts'; import type { SQLiteColumn } from '../columns/common.ts'; import type { SelectedFieldsFlat, SelectedFieldsOrdered } from './select.types.ts'; -import { SelectionProxyHandler } from '~/selection-proxy.ts'; -import { Table } from '~/table.ts'; export type SQLiteDeleteWithout< T extends AnySQLiteDeleteBase, diff --git a/drizzle-orm/src/sqlite-core/query-builders/update.ts b/drizzle-orm/src/sqlite-core/query-builders/update.ts index 9d4543f26..7d25c9921 100644 --- a/drizzle-orm/src/sqlite-core/query-builders/update.ts +++ b/drizzle-orm/src/sqlite-core/query-builders/update.ts @@ -3,16 +3,22 @@ import { entityKind } from '~/entity.ts'; import type { SelectResultFields } from '~/query-builders/select.types.ts'; import { QueryPromise } from '~/query-promise.ts'; import type { RunnableQuery } from '~/runnable-query.ts'; +import { SelectionProxyHandler } from '~/selection-proxy.ts'; import type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts'; import type { SQLiteDialect } from '~/sqlite-core/dialect.ts'; import type { SQLitePreparedQuery, SQLiteSession } from '~/sqlite-core/session.ts'; import { SQLiteTable } from '~/sqlite-core/table.ts'; import type { Subquery } from '~/subquery.ts'; -import { type DrizzleTypeError, mapUpdateSet, orderSelectedFields, type UpdateSet, type ValueOrArray } from '~/utils.ts'; +import { Table } from '~/table.ts'; +import { + type DrizzleTypeError, + mapUpdateSet, + orderSelectedFields, + type UpdateSet, + type ValueOrArray, +} from '~/utils.ts'; import type { SQLiteColumn } from '../columns/common.ts'; import type { SelectedFields, SelectedFieldsOrdered } from './select.types.ts'; -import { SelectionProxyHandler } from '~/selection-proxy.ts'; -import { Table } from '~/table.ts'; export interface SQLiteUpdateConfig { where?: SQL | undefined; diff --git a/drizzle-orm/type-tests/sqlite/delete.ts b/drizzle-orm/type-tests/sqlite/delete.ts index cc6539d98..d943077c8 100644 --- a/drizzle-orm/type-tests/sqlite/delete.ts +++ b/drizzle-orm/type-tests/sqlite/delete.ts @@ -155,4 +155,4 @@ Expect>; { db.delete(users).where(sql``).limit(1).orderBy(sql``); -} \ No newline at end of file +} diff --git a/drizzle-orm/type-tests/sqlite/update.ts b/drizzle-orm/type-tests/sqlite/update.ts index ab60b5d61..cea386b98 100644 --- a/drizzle-orm/type-tests/sqlite/update.ts +++ b/drizzle-orm/type-tests/sqlite/update.ts @@ -136,4 +136,4 @@ Expect>; { db.update(users).set({}).where(sql``).limit(1).orderBy(sql``); -} \ No newline at end of file +} diff --git a/integration-tests/tests/mysql/mysql-common.ts b/integration-tests/tests/mysql/mysql-common.ts index cdee0a1d3..3a804d101 100644 --- a/integration-tests/tests/mysql/mysql-common.ts +++ b/integration-tests/tests/mysql/mysql-common.ts @@ -3821,7 +3821,9 @@ export function tests(driver?: string) { await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); - const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy(asc(usersTable.name)); + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy( + asc(usersTable.name), + ); expect(result).toStrictEqual([ { name: 'Alan', verified: true }, { name: 'Barry', verified: true }, diff --git a/integration-tests/tests/sqlite/sqlite-common.ts b/integration-tests/tests/sqlite/sqlite-common.ts index 2de18bd8f..e637fcb49 100644 --- a/integration-tests/tests/sqlite/sqlite-common.ts +++ b/integration-tests/tests/sqlite/sqlite-common.ts @@ -2890,16 +2890,18 @@ export function tests() { test('update with limit and order by', async (ctx) => { const { db } = ctx.sqlite; - + await db.insert(usersTable).values([ { name: 'Barry', verified: false }, { name: 'Alan', verified: false }, { name: 'Carl', verified: false }, ]); - + await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); - - const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy(asc(usersTable.name)); + + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy( + asc(usersTable.name), + ); expect(result).toStrictEqual([ { name: 'Alan', verified: true }, { name: 'Barry', verified: true }, From 0d7eeaaa796e999d624d80c66a0cde8fdc3157dc Mon Sep 17 00:00:00 2001 From: Mario564 Date: Tue, 17 Sep 2024 10:59:26 -0700 Subject: [PATCH 4/8] Update SQLite test --- .../tests/sqlite/sqlite-common.ts | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/integration-tests/tests/sqlite/sqlite-common.ts b/integration-tests/tests/sqlite/sqlite-common.ts index e637fcb49..8e0adfad4 100644 --- a/integration-tests/tests/sqlite/sqlite-common.ts +++ b/integration-tests/tests/sqlite/sqlite-common.ts @@ -2890,23 +2890,14 @@ export function tests() { test('update with limit and order by', async (ctx) => { const { db } = ctx.sqlite; + // Limit and order by may not be supported by all SQLite databases, so we just verify that the query is correct - await db.insert(usersTable).values([ - { name: 'Barry', verified: false }, - { name: 'Alan', verified: false }, - { name: 'Carl', verified: false }, - ]); - - await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); - - const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy( - asc(usersTable.name), - ); - expect(result).toStrictEqual([ - { name: 'Alan', verified: true }, - { name: 'Barry', verified: true }, - { name: 'Carl', verified: false }, - ]); + const query = db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)).toSQL(); + + expect(query).toStrictEqual({ + sql: 'update "users" set "verified" = ? order by "users"."name" asc limit ?', + params: [1, 2], + }); }); }); From 37c9c7eae9f6fb238c77d1ed76283540a6bc84a1 Mon Sep 17 00:00:00 2001 From: Mario564 Date: Tue, 17 Sep 2024 10:59:43 -0700 Subject: [PATCH 5/8] Format --- integration-tests/tests/sqlite/sqlite-common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/tests/sqlite/sqlite-common.ts b/integration-tests/tests/sqlite/sqlite-common.ts index 8e0adfad4..d9831226b 100644 --- a/integration-tests/tests/sqlite/sqlite-common.ts +++ b/integration-tests/tests/sqlite/sqlite-common.ts @@ -2893,7 +2893,7 @@ export function tests() { // Limit and order by may not be supported by all SQLite databases, so we just verify that the query is correct const query = db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)).toSQL(); - + expect(query).toStrictEqual({ sql: 'update "users" set "verified" = ? order by "users"."name" asc limit ?', params: [1, 2], From 7aba24f545a7962a5f22ce84acb8c58280285d85 Mon Sep 17 00:00:00 2001 From: AndriiSherman Date: Mon, 14 Oct 2024 13:16:04 +0300 Subject: [PATCH 6/8] Update tests --- integration-tests/tests/mysql/mysql-common.ts | 110 +++++++++++------- integration-tests/tests/sqlite/libsql.test.ts | 6 + .../tests/sqlite/sqlite-common.ts | 42 ++++++- 3 files changed, 107 insertions(+), 51 deletions(-) diff --git a/integration-tests/tests/mysql/mysql-common.ts b/integration-tests/tests/mysql/mysql-common.ts index 8c56ccfd8..45b96f391 100644 --- a/integration-tests/tests/mysql/mysql-common.ts +++ b/integration-tests/tests/mysql/mysql-common.ts @@ -3830,54 +3830,74 @@ export function tests(driver?: string) { { name: 'Carl', verified: false }, ]); }); - }); - test('Object keys as column names', async (ctx) => { - const { db } = ctx.mysql; - - // Tests the following: - // Column with required config - // Column with optional config without providing a value - // Column with optional config providing a value - // Column without config - const users = mysqlTable('users', { - id: bigint({ mode: 'number' }).autoincrement().primaryKey(), - createdAt: timestamp(), - updatedAt: timestamp({ fsp: 3 }), - admin: boolean(), - }); - - await db.execute(sql`drop table if exists users`); - await db.execute( - sql` - create table users ( - \`id\` bigint auto_increment primary key, - \`createdAt\` timestamp, - \`updatedAt\` timestamp(3), - \`admin\` boolean - ) - `, - ); - - await db.insert(users).values([ - { createdAt: sql`now() - interval 30 day`, updatedAt: sql`now() - interval 1 day`, admin: true }, - { createdAt: sql`now() - interval 1 day`, updatedAt: sql`now() - interval 30 day`, admin: true }, - { createdAt: sql`now() - interval 1 day`, updatedAt: sql`now() - interval 1 day`, admin: false }, - ]); - const result = await db - .select({ id: users.id, admin: users.admin }) - .from(users) - .where( - and( - gt(users.createdAt, sql`now() - interval 7 day`), - gt(users.updatedAt, sql`now() - interval 7 day`), - ), + test('delete with limit and order by', async (ctx) => { + const { db } = ctx.mysql; + + await db.insert(usersTable).values([ + { name: 'Barry', verified: false }, + { name: 'Alan', verified: false }, + { name: 'Carl', verified: false }, + ]); + + await db.delete(usersTable).where(eq(usersTable.verified, false)).limit(1).orderBy(asc(usersTable.name)); + + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy( + asc(usersTable.name), + ); + expect(result).toStrictEqual([ + { name: 'Barry', verified: false }, + { name: 'Carl', verified: false }, + ]); + }); + + test('Object keys as column names', async (ctx) => { + const { db } = ctx.mysql; + + // Tests the following: + // Column with required config + // Column with optional config without providing a value + // Column with optional config providing a value + // Column without config + const users = mysqlTable('users', { + id: bigint({ mode: 'number' }).autoincrement().primaryKey(), + createdAt: timestamp(), + updatedAt: timestamp({ fsp: 3 }), + admin: boolean(), + }); + + await db.execute(sql`drop table if exists users`); + await db.execute( + sql` + create table users ( + \`id\` bigint auto_increment primary key, + \`createdAt\` timestamp, + \`updatedAt\` timestamp(3), + \`admin\` boolean + ) + `, ); - expect(result).toEqual([ - { id: 3, admin: false }, - ]); + await db.insert(users).values([ + { createdAt: sql`now() - interval 30 day`, updatedAt: sql`now() - interval 1 day`, admin: true }, + { createdAt: sql`now() - interval 1 day`, updatedAt: sql`now() - interval 30 day`, admin: true }, + { createdAt: sql`now() - interval 1 day`, updatedAt: sql`now() - interval 1 day`, admin: false }, + ]); + const result = await db + .select({ id: users.id, admin: users.admin }) + .from(users) + .where( + and( + gt(users.createdAt, sql`now() - interval 7 day`), + gt(users.updatedAt, sql`now() - interval 7 day`), + ), + ); - await db.execute(sql`drop table users`); + expect(result).toEqual([ + { id: 3, admin: false }, + ]); + + await db.execute(sql`drop table users`); + }); }); } diff --git a/integration-tests/tests/sqlite/libsql.test.ts b/integration-tests/tests/sqlite/libsql.test.ts index 71d3b289e..b99d7e9bf 100644 --- a/integration-tests/tests/sqlite/libsql.test.ts +++ b/integration-tests/tests/sqlite/libsql.test.ts @@ -4,6 +4,7 @@ import { sql } from 'drizzle-orm'; import { drizzle, type LibSQLDatabase } from 'drizzle-orm/libsql'; import { migrate } from 'drizzle-orm/libsql/migrator'; import { afterAll, beforeAll, beforeEach, expect, test } from 'vitest'; +import { skipTests } from '~/common'; import { randomString } from '~/utils'; import { anotherUsersMigratorTable, tests, usersMigratorTable } from './sqlite-common'; @@ -87,4 +88,9 @@ test('migrator : migrate with custom table', async () => { await db.run(sql`drop table ${sql.identifier(customTable)}`); }); +skipTests([ + 'delete with limit and order by', + 'update with limit and order by', +]); + tests(); diff --git a/integration-tests/tests/sqlite/sqlite-common.ts b/integration-tests/tests/sqlite/sqlite-common.ts index 0d6a4669b..f31bdbbd2 100644 --- a/integration-tests/tests/sqlite/sqlite-common.ts +++ b/integration-tests/tests/sqlite/sqlite-common.ts @@ -2890,14 +2890,44 @@ export function tests() { test('update with limit and order by', async (ctx) => { const { db } = ctx.sqlite; - // Limit and order by may not be supported by all SQLite databases, so we just verify that the query is correct - const query = db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)).toSQL(); + await db.insert(usersTable).values([ + { name: 'Barry', verified: false }, + { name: 'Alan', verified: false }, + { name: 'Carl', verified: false }, + ]); - expect(query).toStrictEqual({ - sql: 'update "users" set "verified" = ? order by "users"."name" asc limit ?', - params: [1, 2], - }); + await db.update(usersTable).set({ verified: true }).limit(2).orderBy(asc(usersTable.name)); + + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy( + asc(usersTable.name), + ); + + expect(result).toStrictEqual([ + { name: 'Alan', verified: true }, + { name: 'Barry', verified: true }, + { name: 'Carl', verified: false }, + ]); + }); + + test('delete with limit and order by', async (ctx) => { + const { db } = ctx.sqlite; + + await db.insert(usersTable).values([ + { name: 'Barry', verified: false }, + { name: 'Alan', verified: false }, + { name: 'Carl', verified: false }, + ]); + + await db.delete(usersTable).where(eq(usersTable.verified, false)).limit(1).orderBy(asc(usersTable.name)); + + const result = await db.select({ name: usersTable.name, verified: usersTable.verified }).from(usersTable).orderBy( + asc(usersTable.name), + ); + expect(result).toStrictEqual([ + { name: 'Barry', verified: false }, + { name: 'Carl', verified: false }, + ]); }); }); From 9390b9e1930dffbcc407b294b176aee4998bb060 Mon Sep 17 00:00:00 2001 From: AndriiSherman Date: Mon, 14 Oct 2024 13:23:11 +0300 Subject: [PATCH 7/8] Skip sqljs --- integration-tests/tests/sqlite/sql-js.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/tests/sqlite/sql-js.test.ts b/integration-tests/tests/sqlite/sql-js.test.ts index ec3d7b583..4c733835f 100644 --- a/integration-tests/tests/sqlite/sql-js.test.ts +++ b/integration-tests/tests/sqlite/sql-js.test.ts @@ -58,5 +58,7 @@ skipTests([ */ 'transaction rollback', 'nested transaction rollback', + 'delete with limit and order by', + 'update with limit and order by', ]); tests(); From f664b149d1f4583673c4e1f7706f847700781e1d Mon Sep 17 00:00:00 2001 From: AndriiSherman Date: Mon, 14 Oct 2024 13:49:10 +0300 Subject: [PATCH 8/8] Add ignore on neon --- integration-tests/vitest.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/integration-tests/vitest.config.ts b/integration-tests/vitest.config.ts index 034bad147..cbd18f591 100644 --- a/integration-tests/vitest.config.ts +++ b/integration-tests/vitest.config.ts @@ -19,14 +19,12 @@ export default defineConfig({ ...(process.env.SKIP_EXTERNAL_DB_TESTS ? [ 'tests/relational/mysql.planetscale.test.ts', - 'tests/neon-http-batch.test.ts', - 'tests/neon-serverless.test.ts', + 'tests/pg/neon-serverless.test.ts', 'tests/mysql/tidb-serverless.test.ts', 'tests/mysql/mysql-planetscale.test.ts', 'tests/sqlite/libsql.test.ts', 'tests/mysql/tidb-serverless.test.ts', 'tests/sqlite/libsql-batch.test.ts', - 'tests/pg/neon-http.test.ts', 'tests/pg/neon-http-batch.test.ts', ]