Skip to content

Commit 0e6f974

Browse files
committed
Added JSON fields parsing to AWS Data Api RQBv2
1 parent 27d2721 commit 0e6f974

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function construct<
126126
logger,
127127
cache: config.cache,
128128
}, undefined);
129-
const db = new AwsDataApiPgDatabase(dialect, session, relations, schema as V1.RelationalSchemaConfig<any>);
129+
const db = new AwsDataApiPgDatabase(dialect, session, relations, schema as V1.RelationalSchemaConfig<any>, true);
130130
(<any> db).$client = client;
131131
(<any> db).$cache = config.cache;
132132
if ((<any> db).$cache) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class PgDatabase<
7373
readonly session: PgSession<any, any, any, any>,
7474
relations: TRelations,
7575
schema: V1.RelationalSchemaConfig<TSchema> | undefined,
76+
parseRqbJson: boolean = false,
7677
) {
7778
this._ = schema
7879
? {
@@ -117,6 +118,7 @@ export class PgDatabase<
117118
relation,
118119
dialect,
119120
session,
121+
parseRqbJson,
120122
);
121123
}
122124

drizzle-orm/src/pg-core/query-builders/query.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class RelationalQueryBuilder<
2828
private tableConfig: TableRelationalConfig,
2929
private dialect: PgDialect,
3030
private session: PgSession,
31+
private parseJson: boolean,
3132
) {}
3233

3334
findMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(
@@ -41,6 +42,7 @@ export class RelationalQueryBuilder<
4142
this.session,
4243
config as DBQueryConfig<'many'> | undefined ?? true,
4344
'many',
45+
this.parseJson,
4446
);
4547
}
4648

@@ -55,6 +57,7 @@ export class RelationalQueryBuilder<
5557
this.session,
5658
config as DBQueryConfig<'one'> | undefined ?? true,
5759
'first',
60+
this.parseJson,
5861
);
5962
}
6063
}
@@ -77,6 +80,7 @@ export class PgRelationalQuery<TResult> extends QueryPromise<TResult>
7780
private session: PgSession,
7881
private config: DBQueryConfig<'many' | 'one'> | true,
7982
private mode: 'many' | 'first',
83+
private parseJson: boolean,
8084
) {
8185
super();
8286
}
@@ -91,7 +95,7 @@ export class PgRelationalQuery<TResult> extends QueryPromise<TResult>
9195
undefined,
9296
name,
9397
(rawRows, mapColumnValue) => {
94-
const rows = rawRows.map((row) => mapRelationalRow(row, query.selection, mapColumnValue));
98+
const rows = rawRows.map((row) => mapRelationalRow(row, query.selection, mapColumnValue, this.parseJson));
9599
if (this.mode === 'first') {
96100
return rows[0] as TResult;
97101
}

0 commit comments

Comments
 (0)