Skip to content

Commit 362a67a

Browse files
committed
fix next branch following rebase.
.. ... ...
1 parent f22c27f commit 362a67a

File tree

5 files changed

+39
-23
lines changed

5 files changed

+39
-23
lines changed

pnpm-lock.yaml

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/migration/migrator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export class Migrator {
328328
await this.#ensureMigrationLockTableExists()
329329
await this.#ensureLockRowExists()
330330

331-
return await this.#runMigrations(getMigrationDirectionAndStep)
331+
return await this.#runMigrations(getMigrationDirectionAndStep, options)
332332
} catch (error) {
333333
if (error instanceof MigrationResultSetError) {
334334
return error.resultSet

test/node/src/json.test.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,19 +503,21 @@ for (const dialect of DIALECTS) {
503503

504504
expect(typeof result.bigNumber).to.equal(
505505
{
506+
pglite: 'number',
506507
postgres: 'string',
507508
mysql: 'string',
508509
mssql: 'number',
509510
sqlite: 'number',
510-
}[dialect],
511+
}[variant],
511512
)
512513
expect(typeof result.number).to.equal(
513514
{
515+
pglite: 'number',
514516
postgres: 'number',
515517
mysql: 'string',
516518
mssql: 'number',
517519
sqlite: 'number',
518-
}[dialect],
520+
}[variant],
519521
)
520522
expect(typeof result.dehydrated.bigNumber).to.equal('number')
521523
expect(typeof result.dehydrated.number).to.equal('number')
@@ -544,9 +546,9 @@ for (const dialect of DIALECTS) {
544546
mysql: 'object',
545547
mssql: 'object',
546548
sqlite: 'string',
547-
}[dialect],
549+
}[sqlSpec],
548550
)
549-
if (dialect !== 'sqlite') {
551+
if (sqlSpec !== 'sqlite') {
550552
expect(result.date instanceof Date).to.equal(true)
551553
}
552554
expect(typeof result.dehydrated.date).to.equal('string')
@@ -556,19 +558,24 @@ for (const dialect of DIALECTS) {
556558
})
557559

558560
it('should dehydrate Buffer to string in jsonArrayFrom', async () => {
559-
const buffer = {
560-
postgres: sql<Buffer>`'\\xDEADBEEF'::bytea`,
561-
mysql: sql<Buffer>`UNHEX('DEADBEEF')`,
562-
mssql: sql<Buffer>`CAST('DEADBEEF' AS VARBINARY)`,
563-
sqlite: sql<Buffer>`X'DEADBEEF'`,
564-
}[dialect].as('buffer')
561+
const buffer = (
562+
{
563+
pglite: sql<Uint8Array>`'\\xDEADBEEF'::bytea`,
564+
postgres: sql<Buffer>`'\\xDEADBEEF'::bytea`,
565+
mysql: sql<Buffer>`UNHEX('DEADBEEF')`,
566+
mssql: sql<Buffer>`CAST('DEADBEEF' AS VARBINARY)`,
567+
sqlite: sql<Buffer>`X'DEADBEEF'`,
568+
}[variant] satisfies RawBuilder<Buffer | Uint8Array> as RawBuilder<
569+
Buffer | Uint8Array
570+
>
571+
).as('buffer')
565572

566573
const result = await db
567574
.selectNoFrom([
568575
buffer,
569576
jsonObjectFrom(
570577
db.selectNoFrom([
571-
dialect === 'sqlite'
578+
sqlSpec === 'sqlite'
572579
? expressionBuilder()
573580
.cast<string>(buffer.expression, 'text')
574581
.as('buffer')
@@ -581,10 +588,14 @@ for (const dialect of DIALECTS) {
581588
.executeTakeFirstOrThrow()
582589

583590
expect(typeof result.buffer).to.equal('object')
584-
expect(Buffer.isBuffer(result.buffer)).to.equal(true)
591+
expect(
592+
variant === 'pglite'
593+
? ArrayBuffer.isView(result.buffer)
594+
: Buffer.isBuffer(result.buffer),
595+
).to.equal(true)
585596
expect(typeof result.dehydrated.buffer).to.equal('string')
586597

587-
const expectedType0: Buffer = result.buffer
598+
const expectedType0: Buffer | Uint8Array = result.buffer
588599
const expectedType1: string = result.dehydrated.buffer
589600
})
590601
})

test/node/src/migration.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from 'node:path'
22
import { promises as fs } from 'node:fs'
3+
import { setTimeout } from 'node:timers/promises'
34

45
import {
56
FileMigrationProvider,
@@ -1078,7 +1079,7 @@ for (const dialect of DIALECTS) {
10781079
})
10791080
})
10801081

1081-
if (dialect === 'postgres' || dialect === 'mssql') {
1082+
if (sqlSpec === 'postgres' || sqlSpec === 'mssql') {
10821083
describe('custom migration tables in a custom schema', () => {
10831084
it('should create custom migration tables in custom schema', async () => {
10841085
const [migrator, executedUpMethods] = createMigrations(
@@ -1172,7 +1173,7 @@ for (const dialect of DIALECTS) {
11721173
...migrations,
11731174
[config.name]: {
11741175
async up(_db): Promise<void> {
1175-
await sleep(20)
1176+
await setTimeout(20)
11761177

11771178
if (config.error) {
11781179
throw new Error(config.error)
@@ -1182,7 +1183,7 @@ for (const dialect of DIALECTS) {
11821183
},
11831184

11841185
async down(_db): Promise<void> {
1185-
await sleep(20)
1186+
await setTimeout(20)
11861187

11871188
if (config.error) {
11881189
throw new Error(config.error)
@@ -1218,10 +1219,6 @@ for (const dialect of DIALECTS) {
12181219
(it) => it.name === tableName && (!schema || it.schema === schema),
12191220
)
12201221
}
1221-
1222-
function sleep(millis: number): Promise<void> {
1223-
return new Promise((resolve) => setTimeout(resolve, millis))
1224-
}
12251222
})
12261223
}
12271224

test/node/src/update.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ for (const dialect of DIALECTS) {
437437
})
438438
}
439439

440-
if (dialect === 'sqlite') {
440+
if (sqlSpec === 'sqlite') {
441441
it('should order and limit the amount of updated rows and return', async () => {
442442
const query = ctx.db
443443
.updateTable('person')

0 commit comments

Comments
 (0)