Skip to content

Commit 86f5888

Browse files
committed
feat(types): add ValuesListSubquery type
This type allows you to access the columns of a ValuesList after you call its `.as` method, similar to how you would with any other `db.$with()` subquery.
1 parent c7ea923 commit 86f5888

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/generated/$values.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ PgDatabase.prototype.$withValues = function (
118118
})
119119
}
120120

121+
export type ValuesListSubquery<
122+
TAlias extends string,
123+
TSelectedFields extends Record<string, unknown> = Record<string, unknown>,
124+
> = Subquery<TAlias, TSelectedFields> & {
125+
[K in keyof TSelectedFields]: SQL
126+
}
127+
121128
export class ValuesList<
122129
TSelectedFields extends Record<string, unknown> = Record<string, unknown>,
123130
> implements SQLWrapper<unknown>
@@ -137,7 +144,9 @@ export class ValuesList<
137144
typings && (is(typings, PgTable) ? getTableColumns(typings) : typings)
138145
}
139146

140-
as<TAlias extends string>(alias: TAlias): Subquery<TAlias, TSelectedFields> {
147+
as<TAlias extends string>(
148+
alias: TAlias
149+
): ValuesListSubquery<TAlias, TSelectedFields> {
141150
const columnList = this.keys.map(key => this.casing.convert(key))
142151
const selectedFields: Record<string, unknown> = {}
143152
this.keys.forEach((key, index) => {

0 commit comments

Comments
 (0)