Skip to content

Commit 4645e6f

Browse files
Merge pull request #436 from drizzle-team/fix-migrator
Fix migrator
2 parents 67ab2ea + 300fca6 commit 4645e6f

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

changelogs/drizzle-orm/0.23.11.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- 🐛 Fix migrator function for PostgreSQL
2+
3+
> Would suggest to upgrade to this version anyone who is using postgres dialect. `0.23.9` and `0.23.10` are broken for postgresql migrations

drizzle-orm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drizzle-orm",
3-
"version": "0.23.10",
3+
"version": "0.23.11",
44
"description": "Drizzle ORM package for SQL databases",
55
"scripts": {
66
"build": "tsc && resolve-tspaths && cp ../README.md package.json dist/",

drizzle-orm/src/aws-data-api/pg/session.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ export class AwsDataApiPreparedQuery<T extends PreparedQueryConfig> extends Prep
6363

6464
const result = await this.client.send(this.rawQuery);
6565

66-
return result.records?.map((result) => {
67-
const mappedResult = result.map((res) => getValueFromDataApi(res));
66+
return result.records?.map((result: any) => {
67+
const mappedResult = result.map((res: any) => getValueFromDataApi(res));
6868
return mapResultRow<T['execute']>(fields, mappedResult, this.joinsNotNullableMap);
6969
});
7070
}
71+
72+
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {
73+
return this.execute(placeholderValues)
74+
}
7175
}
7276

7377
export interface AwsDataApiSessionOptions {

drizzle-orm/src/pg-core/dialect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PgDialect {
2626
await session.execute(sql`CREATE SCHEMA IF NOT EXISTS "drizzle"`);
2727
await session.execute(migrationTableCreate);
2828

29-
const dbMigrations = await session.execute<{ id: number; hash: string; created_at: string }[]>(
29+
const dbMigrations = await session.all<{ id: number; hash: string; created_at: string }>(
3030
sql`select id, hash, created_at from "drizzle"."__drizzle_migrations" order by created_at desc limit 1`,
3131
);
3232

drizzle-orm/src/pg-core/session.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export abstract class PreparedQuery<T extends PreparedQueryConfig> {
1515
joinsNotNullableMap?: Record<string, boolean>;
1616

1717
abstract execute(placeholderValues?: Record<string, unknown>): Promise<T['execute']>;
18+
19+
/** @internal */
20+
abstract all(placeholderValues?: Record<string, unknown>): Promise<T['all']>;
1821
}
1922

2023
export interface PgTransactionConfig {
@@ -40,6 +43,14 @@ export abstract class PgSession<TQueryResult extends QueryResultHKT = QueryResul
4043
).execute();
4144
}
4245

46+
all<T = unknown>(query: SQL): Promise<T[]> {
47+
return this.prepareQuery<PreparedQueryConfig & { all: T[] }>(
48+
this.dialect.sqlToQuery(query),
49+
undefined,
50+
undefined,
51+
).all();
52+
}
53+
4354
abstract transaction<T>(
4455
transaction: (tx: PgTransaction<TQueryResult>) => Promise<T>,
4556
config?: PgTransactionConfig,

0 commit comments

Comments
 (0)