Skip to content

Commit

Permalink
Merge pull request #2163 from drizzle-team/fix-data-api-session-all
Browse files Browse the repository at this point in the history
Fix session.all result in AWS Data API driver
  • Loading branch information
dankochetov committed Apr 16, 2024
2 parents 1a48cee + a1accd7 commit 4428354
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions drizzle-orm/src/aws-data-api/pg/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export class AwsDataApiPreparedQuery<T extends PreparedQueryConfig> extends PgPr
: result.rows!.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));
}

all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {
return this.execute(placeholderValues);
async all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']> {
const result = await this.execute(placeholderValues) as AwsDataApiPgQueryResult<unknown>;
return result.rows;
}

async values(placeholderValues: Record<string, unknown> = {}): Promise<T['values']> {
Expand Down
13 changes: 11 additions & 2 deletions drizzle-orm/src/pg-core/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class PgDatabase<
declare readonly _: {
readonly schema: TSchema | undefined;
readonly tableNamesMap: Record<string, string>;
readonly session: PgSession<TQueryResult, TFullSchema, TSchema>;
};

query: TFullSchema extends Record<string, never>
Expand All @@ -56,8 +57,16 @@ export class PgDatabase<
schema: RelationalSchemaConfig<TSchema> | undefined,
) {
this._ = schema
? { schema: schema.schema, tableNamesMap: schema.tableNamesMap }
: { schema: undefined, tableNamesMap: {} };
? {
schema: schema.schema,
tableNamesMap: schema.tableNamesMap,
session,
}
: {
schema: undefined,
tableNamesMap: {},
session,
};
this.query = {} as typeof this['query'];
if (this._.schema) {
for (const [tableName, columns] of Object.entries(this._.schema)) {
Expand Down

0 comments on commit 4428354

Please sign in to comment.