pqb 0.67.6 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -604,6 +604,17 @@ interface AfterCommitStandaloneHook {
604
604
  declare const makeConnectRetryConfig: (config: AdapterConfigConnectRetryParam) => AdapterConfigConnectRetry;
605
605
  declare const wrapAdapterFnWithConnectRetry: <Fn extends (...args: any[]) => any>(connectRetryConfig: AdapterConfigConnectRetry, fn: Fn) => Fn;
606
606
  declare const getDriverErrorCode: (err: object) => unknown;
607
+ interface SqlJoinExpression<T extends Column.Pick.QueryColumn> extends Expression<T>, ExpressionTypeMethod {}
608
+ declare class SqlJoinExpression<T extends Column.Pick.QueryColumn = Column.Pick.QueryColumn> extends Expression<T> {
609
+ items: readonly unknown[];
610
+ separator?: RawSqlBase | undefined;
611
+ result: {
612
+ value: T;
613
+ };
614
+ q: ExpressionData;
615
+ constructor(items: readonly unknown[], separator?: RawSqlBase | undefined);
616
+ makeSQL(ctx: ToSqlValues, quotedAs?: string): string;
617
+ }
607
618
  /**
608
619
  * Expression for a SQL identifier reference.
609
620
  * Used to safely quote identifiers in raw SQL queries.
@@ -630,7 +641,7 @@ interface ColumnSchemaGetterTableClass {
630
641
  }
631
642
  type ColumnSchemaGetterColumns<T extends ColumnSchemaGetterTableClass> = T['prototype']['columns']['shape'];
632
643
  interface ColumnTypeSchemaArg {
633
- type: unknown;
644
+ __schemaType: unknown;
634
645
  nullable<T extends Column.Pick.ForNullable>(this: T): Column.Modifiers.Nullable<T, unknown, unknown, unknown>;
635
646
  encode: unknown;
636
647
  parse: unknown;
@@ -664,6 +675,7 @@ interface ColumnSchemaConfig<T extends Column.Pick.Data = Column.Pick.Data> exte
664
675
  bit(max?: number): unknown;
665
676
  uuid(): unknown;
666
677
  json(): T;
678
+ jsonText(): T;
667
679
  inputSchema(this: ColumnSchemaGetterTableClass): unknown;
668
680
  outputSchema(this: ColumnSchemaGetterTableClass): unknown;
669
681
  querySchema(this: ColumnSchemaGetterTableClass): unknown;
@@ -956,7 +968,7 @@ interface TableDataMethods<Key extends PropertyKey> {
956
968
  sql: SqlFn;
957
969
  }
958
970
  type TableDataItemsUniqueColumns<Shape extends Column.QueryColumns, T extends MaybeArray<TableDataItem>> = MaybeArray<TableDataItem> extends T ? never : T extends UniqueTableDataItem<Shape> ? ItemUniqueColumns<Shape, T> : T extends unknown[] ? { [Item in T[number] as PropertyKey]: Item extends UniqueTableDataItem<Shape> ? ItemUniqueColumns<Shape, Item> : never }[PropertyKey] : never;
959
- type ItemUniqueColumns<Shape extends Column.QueryColumns, T extends UniqueTableDataItem<Shape>> = { [Column in T['columns'][number]]: UniqueQueryTypeOrExpression<Shape[Column]['queryType']> };
971
+ type ItemUniqueColumns<Shape extends Column.QueryColumns, T extends UniqueTableDataItem<Shape>> = { [Column in T['columns'][number]]: UniqueQueryTypeOrExpression<Shape[Column]['__queryType']> };
960
972
  type TableDataItemsUniqueColumnTuples<Shape extends Column.QueryColumns, T extends MaybeArray<TableDataItem>> = MaybeArray<TableDataItem> extends T ? never : T extends UniqueTableDataItem<Shape> ? T['columns'] : T extends TableDataItem[] ? Exclude<T[number]['columns'], []> : never;
961
973
  type UniqueQueryTypeOrExpression<T> = T | Expression<Column.Pick.QueryColumnOfType<T>>;
962
974
  type TableDataItemsUniqueConstraints<T extends MaybeArray<TableDataItem>> = MaybeArray<TableDataItem> extends T ? never : T extends UniqueTableDataItem ? T['name'] : T extends UniqueTableDataItem[] ? T[number]['name'] : never;
@@ -1054,16 +1066,33 @@ interface NumberColumnData extends BaseNumberData, Column.Data {
1054
1066
  interface SerialColumnData extends NumberColumnData {
1055
1067
  default: Expression;
1056
1068
  }
1057
- declare abstract class NumberBaseColumn<Schema extends ColumnSchemaConfig, SchemaType extends Schema['type']> extends Column<Schema, number, SchemaType, OperatorsNumber> {
1069
+ declare abstract class NumberBaseColumn<Schema extends ColumnSchemaConfig, SchemaType extends Schema['__schemaType']> extends Column {
1070
+ __schema: Schema;
1071
+ __type: number;
1072
+ __inputType: number;
1073
+ inputSchema: SchemaType;
1058
1074
  data: NumberColumnData;
1075
+ __outputType: number;
1076
+ outputSchema: SchemaType;
1077
+ __queryType: number;
1078
+ querySchema: SchemaType;
1059
1079
  operators: OperatorsNumber;
1060
1080
  }
1061
1081
  declare abstract class IntegerBaseColumn<Schema extends ColumnSchemaConfig> extends NumberBaseColumn<Schema, ReturnType<Schema['int']>> {
1062
1082
  data: NumberColumnData;
1083
+ querySchema: ReturnType<Schema['int']>;
1063
1084
  constructor(schema: Schema);
1064
1085
  }
1065
- declare abstract class NumberAsStringBaseColumn<Schema extends ColumnSchemaConfig, InputType = string | number> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsNumber, InputType> {
1086
+ declare abstract class NumberAsStringBaseColumn<Schema extends ColumnSchemaConfig, InputType = string | number> extends Column {
1087
+ __schema: Schema;
1088
+ __type: string;
1089
+ __inputType: InputType;
1090
+ inputSchema: ReturnType<Schema['stringSchema']>;
1066
1091
  operators: OperatorsNumber;
1092
+ __outputType: string;
1093
+ outputSchema: ReturnType<Schema['stringSchema']>;
1094
+ __queryType: InputType;
1095
+ querySchema: ReturnType<Schema['stringSchema']>;
1067
1096
  data: Column.Data;
1068
1097
  constructor(schema: Schema);
1069
1098
  }
@@ -1073,6 +1102,7 @@ interface DecimalColumnData extends Column.Data {
1073
1102
  }
1074
1103
  declare class DecimalColumn<Schema extends ColumnSchemaConfig> extends NumberAsStringBaseColumn<Schema> {
1075
1104
  data: DecimalColumnData;
1105
+ querySchema: ReturnType<Schema['stringSchema']>;
1076
1106
  operators: OperatorsNumber;
1077
1107
  dataType: "numeric";
1078
1108
  constructor(schema: Schema, numericPrecision?: number, numericScale?: number);
@@ -1082,35 +1112,41 @@ declare class DecimalColumn<Schema extends ColumnSchemaConfig> extends NumberAsS
1082
1112
  type IdentityColumn<T extends Column.Pick.Data> = Column.Modifiers.Default<T, Expression>;
1083
1113
  declare class SmallIntColumn<Schema extends ColumnSchemaConfig> extends IntegerBaseColumn<Schema> {
1084
1114
  dataType: "int2";
1115
+ querySchema: ReturnType<Schema['int']>;
1085
1116
  constructor(schema: Schema);
1086
1117
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1087
- identity<T extends Column>(this: T, options?: TableData.Identity): IdentityColumn<T>;
1118
+ identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): IdentityColumn<T>;
1088
1119
  }
1089
1120
  declare class IntegerColumn<Schema extends ColumnSchemaConfig> extends IntegerBaseColumn<Schema> {
1090
1121
  dataType: "int4";
1122
+ querySchema: ReturnType<Schema['int']>;
1091
1123
  constructor(schema: Schema);
1092
1124
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1093
- identity<T extends Column>(this: T, options?: TableData.Identity): IdentityColumn<T>;
1125
+ identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): IdentityColumn<T>;
1094
1126
  }
1095
1127
  declare class BigIntColumn<Schema extends ColumnSchemaConfig> extends NumberAsStringBaseColumn<Schema, string | number | bigint> {
1096
1128
  dataType: "int8";
1129
+ querySchema: ReturnType<Schema['stringSchema']>;
1097
1130
  constructor(schema: Schema);
1098
1131
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1099
- identity<T extends Column>(this: T, options?: TableData.Identity): IdentityColumn<T>;
1132
+ identity<T extends Column.Pick.Data>(this: T, options?: TableData.Identity): IdentityColumn<T>;
1100
1133
  }
1101
1134
  declare class RealColumn<Schema extends ColumnSchemaConfig> extends NumberBaseColumn<Schema, ReturnType<Schema['number']>> {
1102
1135
  dataType: "float4";
1136
+ querySchema: ReturnType<Schema['number']>;
1103
1137
  constructor(schema: Schema);
1104
1138
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1105
1139
  }
1106
1140
  declare class DoublePrecisionColumn<Schema extends ColumnSchemaConfig> extends NumberAsStringBaseColumn<Schema> {
1107
1141
  dataType: "float8";
1142
+ querySchema: ReturnType<Schema['stringSchema']>;
1108
1143
  constructor(schema: Schema);
1109
1144
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1110
1145
  }
1111
1146
  declare class SmallSerialColumn<Schema extends ColumnSchemaConfig> extends IntegerBaseColumn<Schema> {
1112
1147
  dataType: "int2";
1113
1148
  data: SerialColumnData;
1149
+ querySchema: ReturnType<Schema['int']>;
1114
1150
  constructor(schema: Schema);
1115
1151
  toSQL(): string;
1116
1152
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
@@ -1118,6 +1154,7 @@ declare class SmallSerialColumn<Schema extends ColumnSchemaConfig> extends Integ
1118
1154
  declare class SerialColumn<Schema extends ColumnSchemaConfig> extends IntegerBaseColumn<Schema> {
1119
1155
  dataType: "int4";
1120
1156
  data: SerialColumnData;
1157
+ querySchema: ReturnType<Schema['int']>;
1121
1158
  constructor(schema: Schema);
1122
1159
  toSQL(): string;
1123
1160
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
@@ -1125,6 +1162,7 @@ declare class SerialColumn<Schema extends ColumnSchemaConfig> extends IntegerBas
1125
1162
  declare class BigSerialColumn<Schema extends ColumnSchemaConfig> extends NumberAsStringBaseColumn<Schema> {
1126
1163
  dataType: "int8";
1127
1164
  data: SerialColumnData;
1165
+ querySchema: ReturnType<Schema['stringSchema']>;
1128
1166
  constructor(schema: Schema);
1129
1167
  toSQL(): string;
1130
1168
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
@@ -1138,9 +1176,17 @@ declare const getDateAsDateFn: (column: {
1138
1176
  data: Column.Data;
1139
1177
  dateParsedByDriver?: boolean;
1140
1178
  }) => (value: unknown) => Date;
1141
- declare abstract class DateBaseColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringNumberDate']>, OperatorsDate, DateColumnInput, string, ReturnType<Schema['stringSchema']>> {
1179
+ declare abstract class DateBaseColumn<Schema extends ColumnSchemaConfig> extends Column {
1142
1180
  dateParsedByDriver?: boolean | undefined;
1181
+ __schema: Schema;
1182
+ __type: string;
1183
+ __inputType: DateColumnInput;
1184
+ inputSchema: ReturnType<Schema['stringNumberDate']>;
1143
1185
  data: DateColumnData;
1186
+ __outputType: string;
1187
+ outputSchema: ReturnType<Schema['stringSchema']>;
1188
+ __queryType: DateColumnInput;
1189
+ querySchema: ReturnType<Schema['stringNumberDate']>;
1144
1190
  operators: OperatorsDate;
1145
1191
  asNumber: Schema['dateAsNumber'];
1146
1192
  asDate: Schema['dateAsDate'];
@@ -1170,42 +1216,66 @@ declare class TimestampTZColumn<Schema extends ColumnSchemaConfig> extends DateT
1170
1216
  baseDataType: "timestamp";
1171
1217
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1172
1218
  }
1173
- declare class TimeColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsTime> {
1219
+ declare class TimeColumn<Schema extends ColumnSchemaConfig> extends Column {
1220
+ __schema: Schema;
1221
+ __type: string;
1222
+ __inputType: ReturnType<Schema['stringSchema']>;
1223
+ inputSchema: ReturnType<Schema['stringSchema']>;
1174
1224
  data: DateColumnData & {
1175
1225
  dateTimePrecision?: number;
1176
1226
  };
1227
+ __outputType: string;
1228
+ outputSchema: ReturnType<Schema['stringSchema']>;
1229
+ __queryType: string;
1230
+ querySchema: ReturnType<Schema['stringSchema']>;
1177
1231
  dataType: "time";
1178
1232
  operators: OperatorsTime;
1179
1233
  constructor(schema: Schema, dateTimePrecision?: number);
1180
1234
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1181
1235
  }
1182
- declare class IntervalColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, PostgresInterval, ReturnType<Schema['timeInterval']>, OperatorsDate, Partial<PostgresInterval>, PostgresInterval> {
1236
+ declare class IntervalColumn<Schema extends ColumnSchemaConfig> extends Column {
1237
+ __schema: Schema;
1238
+ __type: PostgresInterval;
1183
1239
  data: Column.Data & {
1184
1240
  fields?: string;
1185
1241
  precision?: number;
1186
1242
  };
1243
+ __inputType: Partial<PostgresInterval>;
1244
+ inputSchema: ReturnType<Schema['timeInterval']>;
1245
+ __outputType: PostgresInterval;
1246
+ outputSchema: ReturnType<Schema['timeInterval']>;
1247
+ __queryType: PostgresInterval;
1248
+ querySchema: ReturnType<Schema['timeInterval']>;
1187
1249
  dataType: "interval";
1188
1250
  operators: OperatorsDate;
1189
1251
  constructor(schema: Schema, fields?: string, precision?: number, parse?: (input: string) => PostgresInterval);
1190
1252
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1191
1253
  toSQL(): string;
1192
1254
  }
1193
- declare class EnumColumn<Schema extends ColumnTypeSchemaArg, SchemaType extends Schema['type'], const T extends readonly string[]> extends Column<Schema, T[number], SchemaType, OperatorsOrdinalText> {
1255
+ declare class EnumColumn<Schema extends ColumnTypeSchemaArg, SchemaType extends Schema['__schemaType'], const T extends readonly string[]> extends Column {
1194
1256
  enumName: string;
1195
1257
  options: T;
1258
+ __schema: Schema;
1196
1259
  operators: OperatorsOrdinalText;
1260
+ __type: T[number];
1261
+ __inputType: T[number];
1262
+ inputSchema: SchemaType;
1263
+ __outputType: T[number];
1264
+ outputSchema: SchemaType;
1265
+ __queryType: T[number];
1266
+ querySchema: SchemaType;
1197
1267
  dataType: string;
1198
1268
  constructor(schema: Schema, enumName: string, options: T, schemaType: SchemaType);
1199
1269
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1200
1270
  toSQL(): string;
1201
1271
  }
1202
1272
  interface ArrayColumnValue {
1203
- type: unknown;
1273
+ __type: unknown;
1204
1274
  inputSchema: any;
1205
- inputType: unknown;
1206
- outputType: unknown;
1275
+ __inputType: unknown;
1276
+ __outputType: unknown;
1207
1277
  outputSchema: any;
1208
- queryType: any;
1278
+ __queryType: any;
1209
1279
  querySchema: any;
1210
1280
  toSQL(): string;
1211
1281
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
@@ -1215,67 +1285,90 @@ interface ArrayData<Item extends ArrayColumnValue> extends Column.Data, ArrayMet
1215
1285
  item: Item;
1216
1286
  arrayDims: number;
1217
1287
  }
1218
- declare class ArrayColumn<Schema extends ColumnTypeSchemaArg, Item extends ArrayColumnValue, InputType, OutputType, QueryType> extends Column<Schema, Item['type'][], InputType, OperatorsArray<Item['queryType']>, Item['inputType'][], Item['outputType'][], OutputType, Item['queryType'][], QueryType> {
1288
+ declare class ArrayColumn<Schema extends ColumnTypeSchemaArg, Item extends ArrayColumnValue, InputType, OutputType, QueryType> extends Column {
1289
+ __schema: Schema;
1219
1290
  dataType: "array";
1220
- operators: OperatorsArray<Item["queryType"]>;
1291
+ operators: OperatorsArray<Item["__queryType"]>;
1221
1292
  data: ArrayData<Item>;
1222
- constructor(schema: Schema, item: Item, inputType: InputType, defaultEncode?: (input: unknown) => unknown, outputType?: OutputType, queryType?: QueryType);
1293
+ __type: Item['__type'][];
1294
+ __inputType: Item['__type'][];
1295
+ inputSchema: InputType;
1296
+ __outputType: Item['__outputType'][];
1297
+ outputSchema: OutputType;
1298
+ __queryType: Item['__queryType'][];
1299
+ querySchema: QueryType;
1300
+ constructor(schema: Schema, item: Item, __inputType: InputType, defaultEncode?: (input: unknown) => unknown, __outputType?: OutputType, __queryType?: QueryType);
1223
1301
  toSQL(): string;
1224
1302
  toCode(this: ArrayColumn<ColumnSchemaConfig, ArrayColumnValue, unknown, unknown, unknown>, ctx: ColumnToCodeCtx, key: string): Code;
1225
1303
  }
1226
- declare class JSONColumn<T, Schema extends ColumnTypeSchemaArg, InputSchema = Schema['type']> extends Column<Schema, T, InputSchema, OperatorsJson> {
1304
+ declare class JSONColumn<T, Schema extends ColumnTypeSchemaArg, InputSchema = Schema['__schemaType']> extends Column {
1305
+ __schema: Schema;
1227
1306
  dataType: "jsonb";
1307
+ __type: T;
1308
+ __inputType: T;
1309
+ inputSchema: InputSchema;
1310
+ __outputType: T;
1311
+ outputSchema: InputSchema;
1312
+ __queryType: T;
1313
+ querySchema: InputSchema;
1228
1314
  operators: OperatorsJson;
1229
- constructor(schema: Schema, inputType: Schema['type'], encodedByDriver?: boolean);
1315
+ constructor(schema: Schema, __inputType: InputSchema, encodedByDriver?: boolean);
1230
1316
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1231
1317
  }
1232
- declare class JSONTextColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, unknown, ReturnType<Schema['unknown']>, OperatorsText> {
1318
+ declare class JSONTextColumn<T, Schema extends ColumnTypeSchemaArg, InputSchema = Schema['__schemaType']> extends Column {
1319
+ __schema: Schema;
1233
1320
  dataType: "json";
1321
+ __type: T;
1322
+ __inputType: T;
1323
+ inputSchema: InputSchema;
1324
+ __outputType: T;
1325
+ outputSchema: InputSchema;
1326
+ __queryType: T;
1327
+ querySchema: InputSchema;
1234
1328
  operators: OperatorsText;
1235
1329
  private static _instance;
1236
- static get instance(): JSONTextColumn<DefaultSchemaConfig>;
1237
- constructor(schema: Schema);
1330
+ static get instance(): JSONTextColumn<unknown, DefaultSchemaConfig, unknown>;
1331
+ constructor(schema: Schema, __inputType: InputSchema);
1238
1332
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1239
1333
  }
1240
1334
  interface DefaultSchemaConfig extends ColumnSchemaConfig<Column> {
1241
- parse<T extends Column.Pick.ForParse, Output>(this: T, fn: (input: T['type']) => Output): Column.Modifiers.Parse<T, unknown, Output>;
1335
+ parse<T extends Column.Pick.ForParse, Output>(this: T, fn: (input: T['__type']) => Output): Column.Modifiers.Parse<T, unknown, Output>;
1242
1336
  parseNull<T extends Column.Pick.ForParseNull, Output>(this: T, fn: () => Output): Column.Modifiers.ParseNull<T, unknown, Output>;
1243
- encode<T extends {
1244
- type: unknown;
1245
- }, Input>(this: T, fn: (input: Input) => unknown): Column.Modifiers.Encode<T, unknown, Input>;
1337
+ encode<T extends Column.Pick.Type, Input>(this: T, fn: (input: Input) => unknown): Column.Modifiers.Encode<T, unknown, Input>;
1246
1338
  /**
1247
1339
  * @deprecated use narrowType instead
1248
1340
  */
1249
1341
  asType<T, Types extends {
1250
1342
  type: unknown;
1251
- inputType: unknown;
1252
- outputType: unknown;
1253
- queryType: unknown;
1343
+ __inputType: unknown;
1344
+ __outputType: unknown;
1345
+ __queryType: unknown;
1254
1346
  }>(this: T, _fn: (type: <Type, Input = Type, Output = Type, Query = Type>() => {
1255
1347
  type: Type;
1256
- inputType: Input;
1257
- outputType: Output;
1258
- queryType: Query;
1259
- }) => Types): { [K in keyof T]: K extends keyof Types ? Types[K] : T[K] };
1260
- narrowType<T extends Column.InputOutputQueryTypes, Types extends Column.InputOutputQueryTypes>(this: T, _fn: (type: <Type extends (T['inputType'] extends T['outputType'] & T['queryType'] ? T['outputType'] & T['queryType'] : T['inputType'] & T['outputType'] & T['queryType'])>() => {
1261
- inputType: T['inputType'] extends never ? never : Type;
1262
- outputType: Type;
1263
- queryType: Type;
1348
+ __inputType: Input;
1349
+ __outputType: Output;
1350
+ __queryType: Query;
1351
+ }) => Types): { [K in keyof T]: K extends '__type' ? Types['type'] : K extends keyof Types ? Types[K] : T[K] };
1352
+ narrowType<T extends Column.InputOutputQueryTypes, Types extends Column.InputOutputQueryTypes>(this: T, _fn: (type: <Type extends (T['__inputType'] extends T['__outputType'] & T['__queryType'] ? T['__outputType'] & T['__queryType'] : T['__inputType'] & T['__outputType'] & T['__queryType'])>() => {
1353
+ __inputType: T['__inputType'] extends never ? never : Type;
1354
+ __outputType: Type;
1355
+ __queryType: Type;
1264
1356
  }) => Types): { [K in keyof T]: K extends keyof Types ? Types[K] : T[K] };
1265
1357
  narrowAllTypes<T extends Column.InputOutputQueryTypes, Types extends Column.InputOutputQueryTypes>(this: T, _fn: (type: <Types extends {
1266
- input?: T['inputType'];
1267
- output?: T['outputType'];
1268
- query?: T['queryType'];
1358
+ input?: T['__inputType'];
1359
+ output?: T['__outputType'];
1360
+ query?: T['__queryType'];
1269
1361
  }>() => {
1270
- inputType: undefined extends Types['input'] ? T['inputType'] : Types['input'];
1271
- outputType: undefined extends Types['output'] ? T['outputType'] : Types['output'];
1272
- queryType: undefined extends Types['query'] ? T['queryType'] : Types['query'];
1362
+ __inputType: undefined extends Types['input'] ? T['__inputType'] : Types['input'];
1363
+ __outputType: undefined extends Types['output'] ? T['__outputType'] : Types['output'];
1364
+ __queryType: undefined extends Types['query'] ? T['__queryType'] : Types['query'];
1273
1365
  }) => Types): { [K in keyof T]: K extends keyof Types ? Types[K] : T[K] };
1274
- dateAsNumber<T extends Column>(this: T): Column.Modifiers.Parse<T, unknown, number>;
1275
- dateAsDate<T extends Column>(this: T): Column.Modifiers.Parse<T, unknown, Date>;
1366
+ dateAsNumber<T extends Column.Pick.ForParse>(this: T): Column.Modifiers.Parse<T, unknown, number>;
1367
+ dateAsDate<T extends Column.Pick.ForParse>(this: T): Column.Modifiers.Parse<T, unknown, Date>;
1276
1368
  enum<const T extends readonly [string, ...string[]]>(dataType: string, type: T): EnumColumn<DefaultSchemaConfig, unknown, T>;
1277
1369
  array<Item extends ArrayColumnValue>(item: Item): ArrayColumn<DefaultSchemaConfig, Item, unknown, unknown, unknown>;
1278
1370
  json<T>(): JSONColumn<unknown extends T ? MaybeArray<string | number | boolean | object> : T, DefaultSchemaConfig>;
1371
+ jsonText<T>(): JSONTextColumn<unknown extends T ? MaybeArray<string | number | boolean | object> : T, DefaultSchemaConfig>;
1279
1372
  inputSchema(): undefined;
1280
1373
  outputSchema(): undefined;
1281
1374
  querySchema(): undefined;
@@ -1302,8 +1395,16 @@ interface DefaultSchemaConfig extends ColumnSchemaConfig<Column> {
1302
1395
  declare const defaultSchemaConfig: (options?: AdapterSchemaConfigOptions) => DefaultSchemaConfig;
1303
1396
  declare const internalSchemaConfig: DefaultSchemaConfig;
1304
1397
  type TextColumnData = StringData;
1305
- declare abstract class TextBaseColumn<Schema extends ColumnSchemaConfig, Ops = OperatorsText> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, Ops> {
1398
+ declare abstract class TextBaseColumn<Schema extends ColumnSchemaConfig, Ops = OperatorsText> extends Column {
1399
+ __schema: Schema;
1400
+ __type: string;
1401
+ __inputType: string;
1402
+ inputSchema: ReturnType<Schema['stringSchema']>;
1306
1403
  data: TextColumnData;
1404
+ __outputType: string;
1405
+ outputSchema: ReturnType<Schema['stringSchema']>;
1406
+ __queryType: string;
1407
+ querySchema: ReturnType<Schema['stringSchema']>;
1307
1408
  operators: Ops;
1308
1409
  constructor(schema: Schema, schemaType?: ReturnType<Schema['stringSchema']>);
1309
1410
  }
@@ -1329,93 +1430,206 @@ declare class TextColumn<Schema extends ColumnSchemaConfig> extends TextBaseColu
1329
1430
  minArg?: number;
1330
1431
  maxArg?: number;
1331
1432
  };
1433
+ querySchema: ReturnType<Schema['stringSchema']>;
1332
1434
  operators: OperatorsOrdinalText;
1333
1435
  private static _instance;
1334
1436
  static get instance(): TextColumn<DefaultSchemaConfig>;
1335
1437
  constructor(schema: Schema);
1336
1438
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1337
1439
  }
1338
- declare class ByteaColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['buffer']>, OperatorsOrdinalText, Buffer, Buffer, ReturnType<Schema['buffer']>, string, ReturnType<Schema['stringSchema']>> {
1440
+ declare class ByteaColumn<Schema extends ColumnSchemaConfig> extends Column {
1441
+ __schema: Schema;
1339
1442
  dataType: "bytea";
1340
1443
  operators: OperatorsOrdinalText;
1444
+ __type: string;
1445
+ __inputType: Buffer;
1446
+ inputSchema: ReturnType<Schema['buffer']>;
1447
+ __outputType: Buffer;
1448
+ outputSchema: ReturnType<Schema['buffer']>;
1449
+ __queryType: string;
1450
+ querySchema: ReturnType<Schema['stringSchema']>;
1341
1451
  constructor(schema: Schema);
1342
1452
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1343
1453
  }
1344
- declare class PointColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1454
+ declare class PointColumn<Schema extends ColumnSchemaConfig> extends Column {
1455
+ __schema: Schema;
1345
1456
  dataType: "point";
1457
+ __type: string;
1458
+ __inputType: string;
1459
+ inputSchema: ReturnType<Schema['stringSchema']>;
1460
+ __outputType: string;
1461
+ outputSchema: ReturnType<Schema['stringSchema']>;
1462
+ __queryType: string;
1463
+ querySchema: ReturnType<Schema['stringSchema']>;
1346
1464
  operators: OperatorsText;
1347
1465
  constructor(schema: Schema);
1348
1466
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1349
1467
  }
1350
- declare class LineColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1468
+ declare class LineColumn<Schema extends ColumnSchemaConfig> extends Column {
1469
+ __schema: Schema;
1351
1470
  dataType: "line";
1471
+ __type: string;
1472
+ __inputType: string;
1473
+ inputSchema: ReturnType<Schema['stringSchema']>;
1474
+ __outputType: string;
1475
+ outputSchema: ReturnType<Schema['stringSchema']>;
1476
+ __queryType: string;
1477
+ querySchema: ReturnType<Schema['stringSchema']>;
1352
1478
  operators: OperatorsText;
1353
1479
  constructor(schema: Schema);
1354
1480
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1355
1481
  }
1356
- declare class LsegColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1482
+ declare class LsegColumn<Schema extends ColumnSchemaConfig> extends Column {
1483
+ __schema: Schema;
1357
1484
  dataType: "lseg";
1485
+ __type: string;
1486
+ __inputType: string;
1487
+ inputSchema: ReturnType<Schema['stringSchema']>;
1488
+ __outputType: string;
1489
+ outputSchema: ReturnType<Schema['stringSchema']>;
1490
+ __queryType: string;
1491
+ querySchema: ReturnType<Schema['stringSchema']>;
1358
1492
  operators: OperatorsText;
1359
1493
  constructor(schema: Schema);
1360
1494
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1361
1495
  }
1362
- declare class BoxColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1496
+ declare class BoxColumn<Schema extends ColumnSchemaConfig> extends Column {
1497
+ __schema: Schema;
1363
1498
  dataType: "box";
1499
+ __type: string;
1500
+ __inputType: string;
1501
+ inputSchema: ReturnType<Schema['stringSchema']>;
1502
+ __outputType: string;
1503
+ outputSchema: ReturnType<Schema['stringSchema']>;
1504
+ __queryType: string;
1505
+ querySchema: ReturnType<Schema['stringSchema']>;
1364
1506
  operators: OperatorsText;
1365
1507
  constructor(schema: Schema);
1366
1508
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1367
1509
  }
1368
- declare class PathColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1510
+ declare class PathColumn<Schema extends ColumnSchemaConfig> extends Column {
1511
+ __schema: Schema;
1369
1512
  dataType: "path";
1513
+ __type: string;
1514
+ __inputType: string;
1515
+ inputSchema: ReturnType<Schema['stringSchema']>;
1516
+ __outputType: string;
1517
+ outputSchema: ReturnType<Schema['stringSchema']>;
1518
+ __queryType: string;
1519
+ querySchema: ReturnType<Schema['stringSchema']>;
1370
1520
  operators: OperatorsText;
1371
1521
  constructor(schema: Schema);
1372
1522
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1373
1523
  }
1374
- declare class PolygonColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1524
+ declare class PolygonColumn<Schema extends ColumnSchemaConfig> extends Column {
1525
+ __schema: Schema;
1375
1526
  dataType: "polygon";
1527
+ __type: string;
1528
+ __inputType: string;
1529
+ inputSchema: ReturnType<Schema['stringSchema']>;
1530
+ __outputType: string;
1531
+ outputSchema: ReturnType<Schema['stringSchema']>;
1532
+ __queryType: string;
1533
+ querySchema: ReturnType<Schema['stringSchema']>;
1376
1534
  operators: OperatorsText;
1377
1535
  constructor(schema: Schema);
1378
1536
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1379
1537
  }
1380
- declare class CircleColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1538
+ declare class CircleColumn<Schema extends ColumnSchemaConfig> extends Column {
1539
+ __schema: Schema;
1381
1540
  dataType: "circle";
1541
+ __type: string;
1542
+ __inputType: string;
1543
+ inputSchema: ReturnType<Schema['stringSchema']>;
1544
+ __outputType: string;
1545
+ outputSchema: ReturnType<Schema['stringSchema']>;
1546
+ __queryType: string;
1547
+ querySchema: ReturnType<Schema['stringSchema']>;
1382
1548
  operators: OperatorsText;
1383
1549
  constructor(schema: Schema);
1384
1550
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1385
1551
  }
1386
- declare class MoneyColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['number']>, OperatorsNumber, string | number, number, ReturnType<Schema['number']>, string | number> {
1552
+ declare class MoneyColumn<Schema extends ColumnSchemaConfig> extends Column {
1553
+ __schema: Schema;
1387
1554
  dataType: "money";
1555
+ __type: string;
1388
1556
  data: NumberColumnData;
1557
+ __inputType: string | number;
1558
+ inputSchema: ReturnType<Schema['number']>;
1559
+ __outputType: number;
1560
+ outputSchema: ReturnType<Schema['number']>;
1561
+ __queryType: string | number;
1562
+ querySchema: ReturnType<Schema['number']>;
1389
1563
  operators: OperatorsNumber;
1390
1564
  constructor(schema: Schema);
1391
1565
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1392
1566
  }
1393
- declare class CidrColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1567
+ declare class CidrColumn<Schema extends ColumnSchemaConfig> extends Column {
1568
+ __schema: Schema;
1394
1569
  dataType: "cidr";
1570
+ __type: string;
1571
+ __inputType: string;
1572
+ inputSchema: ReturnType<Schema['stringSchema']>;
1573
+ __outputType: string;
1574
+ outputSchema: ReturnType<Schema['stringSchema']>;
1575
+ __queryType: string;
1576
+ querySchema: ReturnType<Schema['stringSchema']>;
1395
1577
  operators: OperatorsText;
1396
1578
  constructor(schema: Schema);
1397
1579
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1398
1580
  }
1399
- declare class InetColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsOrdinalText> {
1581
+ declare class InetColumn<Schema extends ColumnSchemaConfig> extends Column {
1582
+ __schema: Schema;
1400
1583
  dataType: "inet";
1584
+ __type: string;
1585
+ __inputType: string;
1586
+ inputSchema: ReturnType<Schema['stringSchema']>;
1587
+ __outputType: string;
1588
+ outputSchema: ReturnType<Schema['stringSchema']>;
1589
+ __queryType: string;
1590
+ querySchema: ReturnType<Schema['stringSchema']>;
1401
1591
  operators: OperatorsOrdinalText;
1402
1592
  constructor(schema: Schema);
1403
1593
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1404
1594
  }
1405
- declare class MacAddrColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsOrdinalText> {
1595
+ declare class MacAddrColumn<Schema extends ColumnSchemaConfig> extends Column {
1596
+ __schema: Schema;
1406
1597
  dataType: "macaddr";
1598
+ __type: string;
1599
+ __inputType: string;
1600
+ inputSchema: ReturnType<Schema['stringSchema']>;
1601
+ __outputType: string;
1602
+ outputSchema: ReturnType<Schema['stringSchema']>;
1603
+ __queryType: string;
1604
+ querySchema: ReturnType<Schema['stringSchema']>;
1407
1605
  operators: OperatorsOrdinalText;
1408
1606
  constructor(schema: Schema);
1409
1607
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1410
1608
  }
1411
- declare class MacAddr8Column<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsOrdinalText> {
1609
+ declare class MacAddr8Column<Schema extends ColumnSchemaConfig> extends Column {
1610
+ __schema: Schema;
1412
1611
  dataType: "macaddr8";
1612
+ __type: string;
1613
+ __inputType: string;
1614
+ inputSchema: ReturnType<Schema['stringSchema']>;
1615
+ __outputType: string;
1616
+ outputSchema: ReturnType<Schema['stringSchema']>;
1617
+ __queryType: string;
1618
+ querySchema: ReturnType<Schema['stringSchema']>;
1413
1619
  operators: OperatorsOrdinalText;
1414
1620
  constructor(schema: Schema);
1415
1621
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1416
1622
  }
1417
- declare class BitColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['bit']>, OperatorsOrdinalText> {
1623
+ declare class BitColumn<Schema extends ColumnSchemaConfig> extends Column {
1624
+ __schema: Schema;
1418
1625
  dataType: "bit";
1626
+ __type: string;
1627
+ __inputType: string;
1628
+ inputSchema: ReturnType<Schema['bit']>;
1629
+ __outputType: string;
1630
+ outputSchema: ReturnType<Schema['bit']>;
1631
+ __queryType: string;
1632
+ querySchema: ReturnType<Schema['bit']>;
1419
1633
  operators: OperatorsOrdinalText;
1420
1634
  data: Column.Data & {
1421
1635
  length: number;
@@ -1424,8 +1638,16 @@ declare class BitColumn<Schema extends ColumnSchemaConfig> extends Column<Schema
1424
1638
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1425
1639
  toSQL(): string;
1426
1640
  }
1427
- declare class BitVaryingColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['bit']>, OperatorsOrdinalText> {
1641
+ declare class BitVaryingColumn<Schema extends ColumnSchemaConfig> extends Column {
1642
+ __schema: Schema;
1428
1643
  dataType: "varbit";
1644
+ __type: string;
1645
+ __inputType: string;
1646
+ inputSchema: ReturnType<Schema['bit']>;
1647
+ __outputType: string;
1648
+ outputSchema: ReturnType<Schema['bit']>;
1649
+ __queryType: string;
1650
+ querySchema: ReturnType<Schema['bit']>;
1429
1651
  operators: OperatorsOrdinalText;
1430
1652
  data: Column.Data & {
1431
1653
  length?: number;
@@ -1435,9 +1657,17 @@ declare class BitVaryingColumn<Schema extends ColumnSchemaConfig> extends Column
1435
1657
  toSQL(): string;
1436
1658
  }
1437
1659
  type TsVectorGeneratedColumns = string[] | SearchWeightRecord;
1438
- declare class TsVectorColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsOrdinalText> {
1660
+ declare class TsVectorColumn<Schema extends ColumnSchemaConfig> extends Column {
1439
1661
  defaultLanguage: string;
1662
+ __schema: Schema;
1440
1663
  dataType: "tsvector";
1664
+ __type: string;
1665
+ __inputType: string;
1666
+ inputSchema: ReturnType<Schema['stringSchema']>;
1667
+ __outputType: string;
1668
+ outputSchema: ReturnType<Schema['stringSchema']>;
1669
+ __queryType: string;
1670
+ querySchema: ReturnType<Schema['stringSchema']>;
1441
1671
  operators: OperatorsOrdinalText;
1442
1672
  constructor(schema: Schema, defaultLanguage?: string);
1443
1673
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
@@ -1467,14 +1697,30 @@ declare class TsVectorColumn<Schema extends ColumnSchemaConfig> extends Column<S
1467
1697
  */
1468
1698
  generated<T extends Column.Pick.Data>(this: T, ...args: StaticSQLArgs | [language: string, columns: TsVectorGeneratedColumns] | [columns: TsVectorGeneratedColumns]): Column.Modifiers.Generated<T>;
1469
1699
  }
1470
- declare class TsQueryColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsOrdinalText> {
1700
+ declare class TsQueryColumn<Schema extends ColumnSchemaConfig> extends Column {
1701
+ __schema: Schema;
1471
1702
  dataType: "tsquery";
1703
+ __type: string;
1704
+ __inputType: string;
1705
+ inputSchema: ReturnType<Schema['stringSchema']>;
1706
+ __outputType: string;
1707
+ outputSchema: ReturnType<Schema['stringSchema']>;
1708
+ __queryType: string;
1709
+ querySchema: ReturnType<Schema['stringSchema']>;
1472
1710
  operators: OperatorsOrdinalText;
1473
1711
  constructor(schema: Schema);
1474
1712
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1475
1713
  }
1476
- declare class UUIDColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['uuid']>, OperatorsOrdinalText> {
1714
+ declare class UUIDColumn<Schema extends ColumnSchemaConfig> extends Column {
1715
+ __schema: Schema;
1477
1716
  dataType: "uuid";
1717
+ __type: string;
1718
+ __inputType: string;
1719
+ inputSchema: ReturnType<Schema['uuid']>;
1720
+ __outputType: string;
1721
+ outputSchema: ReturnType<Schema['uuid']>;
1722
+ __queryType: string;
1723
+ querySchema: ReturnType<Schema['uuid']>;
1478
1724
  operators: OperatorsOrdinalText;
1479
1725
  constructor(schema: Schema);
1480
1726
  /**
@@ -1489,8 +1735,16 @@ declare class UUIDColumn<Schema extends ColumnSchemaConfig> extends Column<Schem
1489
1735
  };
1490
1736
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1491
1737
  }
1492
- declare class XMLColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, string, ReturnType<Schema['stringSchema']>, OperatorsText> {
1738
+ declare class XMLColumn<Schema extends ColumnSchemaConfig> extends Column {
1739
+ __schema: Schema;
1493
1740
  dataType: "xml";
1741
+ __type: string;
1742
+ __inputType: string;
1743
+ inputSchema: ReturnType<Schema['stringSchema']>;
1744
+ __outputType: string;
1745
+ outputSchema: ReturnType<Schema['stringSchema']>;
1746
+ __queryType: string;
1747
+ querySchema: ReturnType<Schema['stringSchema']>;
1494
1748
  operators: OperatorsText;
1495
1749
  private static _instance;
1496
1750
  static get instance(): XMLColumn<DefaultSchemaConfig>;
@@ -1498,18 +1752,28 @@ declare class XMLColumn<Schema extends ColumnSchemaConfig> extends Column<Schema
1498
1752
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1499
1753
  }
1500
1754
  declare class CitextColumn<Schema extends ColumnSchemaConfig> extends TextBaseColumn<Schema, OperatorsOrdinalText> {
1755
+ __schema: Schema;
1501
1756
  dataType: "citext";
1502
1757
  data: TextColumnData & {
1503
1758
  minArg?: number;
1504
1759
  maxArg?: number;
1505
1760
  };
1761
+ querySchema: ReturnType<Schema['stringSchema']>;
1506
1762
  operators: OperatorsOrdinalText;
1507
1763
  constructor(schema: Schema);
1508
1764
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1509
1765
  }
1510
- declare class BooleanColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, boolean, ReturnType<Schema['boolean']>, OperatorsBoolean> {
1766
+ declare class BooleanColumn<Schema extends ColumnSchemaConfig> extends Column {
1767
+ __schema: Schema;
1511
1768
  dataType: "bool";
1512
1769
  operators: OperatorsBoolean;
1770
+ __type: boolean;
1771
+ __inputType: boolean;
1772
+ inputSchema: ReturnType<Schema['boolean']>;
1773
+ __outputType: boolean;
1774
+ outputSchema: ReturnType<Schema['boolean']>;
1775
+ __queryType: boolean;
1776
+ querySchema: ReturnType<Schema['boolean']>;
1513
1777
  private static _instance;
1514
1778
  static get instance(): BooleanColumn<DefaultSchemaConfig>;
1515
1779
  constructor(schema: Schema);
@@ -1533,20 +1797,29 @@ interface TimestampHelpers {
1533
1797
  timestampNoTZ(): T;
1534
1798
  }): Timestamps<T>;
1535
1799
  }
1536
- declare class CustomTypeColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, unknown, ReturnType<Schema['unknown']>, OperatorsAny> {
1800
+ declare class CustomTypeColumn<Schema extends ColumnSchemaConfig> extends Column {
1537
1801
  typeName: string;
1538
1802
  typeSchema?: string | undefined;
1803
+ __schema: Schema;
1539
1804
  operators: OperatorsAny;
1805
+ __type: unknown;
1806
+ __inputType: unknown;
1807
+ inputSchema: ReturnType<Schema['unknown']>;
1808
+ __outputType: unknown;
1809
+ outputSchema: ReturnType<Schema['unknown']>;
1810
+ __queryType: unknown;
1811
+ querySchema: ReturnType<Schema['unknown']>;
1812
+ data: Column.Data;
1540
1813
  dataType: string;
1541
1814
  constructor(schema: Schema, typeName: string, typeSchema?: string | undefined, extension?: string);
1542
1815
  toCode(ctx: ColumnToCodeCtx, key: string): Code;
1543
1816
  as<T extends {
1544
- inputType: unknown;
1545
- outputType: unknown;
1817
+ __inputType: unknown;
1818
+ __outputType: unknown;
1546
1819
  data: Column.Data;
1547
1820
  }, C extends {
1548
- inputType: T['inputType'];
1549
- outputType: T['outputType'];
1821
+ __inputType: T['__inputType'];
1822
+ __outputType: T['__outputType'];
1550
1823
  }>(this: T, column: C): C;
1551
1824
  }
1552
1825
  declare class DomainColumn<Schema extends ColumnSchemaConfig> extends CustomTypeColumn<Schema> {
@@ -1557,8 +1830,16 @@ interface PostgisPoint {
1557
1830
  lat: number;
1558
1831
  srid?: number;
1559
1832
  }
1560
- declare class PostgisGeographyPointColumn<Schema extends ColumnSchemaConfig> extends Column<Schema, PostgisPoint, ReturnType<Schema['geographyPointSchema']>, OperatorsAny> {
1833
+ declare class PostgisGeographyPointColumn<Schema extends ColumnSchemaConfig> extends Column {
1834
+ __schema: Schema;
1561
1835
  dataType: string;
1836
+ __type: PostgisPoint;
1837
+ __inputType: PostgisPoint;
1838
+ inputSchema: ReturnType<Schema['geographyPointSchema']>;
1839
+ __outputType: PostgisPoint;
1840
+ outputSchema: ReturnType<Schema['geographyPointSchema']>;
1841
+ __queryType: PostgisPoint;
1842
+ querySchema: ReturnType<Schema['geographyPointSchema']>;
1562
1843
  operators: OperatorsAny;
1563
1844
  static encode: ({
1564
1845
  srid,
@@ -1617,7 +1898,7 @@ interface DefaultColumnTypes<SchemaConfig extends ColumnSchemaConfig> extends Ti
1617
1898
  uuid(): UUIDColumn<SchemaConfig>;
1618
1899
  xml(): XMLColumn<SchemaConfig>;
1619
1900
  json: SchemaConfig['json'];
1620
- jsonText(): JSONTextColumn<SchemaConfig>;
1901
+ jsonText: SchemaConfig['jsonText'];
1621
1902
  type(dataType: string): CustomTypeColumn<SchemaConfig>;
1622
1903
  domain(dataType: string): DomainColumn<SchemaConfig>;
1623
1904
  geography: {
@@ -1700,8 +1981,8 @@ interface QueryThen<T> {
1700
1981
  type QueryThenShallowSimplify<T> = QueryThen<ShallowSimplify<T>>;
1701
1982
  type QueryThenShallowSimplifyArr<T> = QueryThen<ShallowSimplify<T>[]>;
1702
1983
  type QueryThenShallowSimplifyOptional<T> = QueryThen<ShallowSimplify<T> | undefined>;
1703
- type QueryThenByQuery<T extends PickQueryReturnType, Result extends Column.QueryColumns> = T['returnType'] extends undefined | 'all' ? QueryThenShallowSimplifyArr<ColumnsShape.Output<Result>> : T['returnType'] extends 'one' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<Result>> : T['returnType'] extends 'oneOrThrow' ? QueryThenShallowSimplify<ColumnsShape.Output<Result>> : T['returnType'] extends 'value' ? QueryThen<Result['value']['outputType'] | undefined> : T['returnType'] extends 'valueOrThrow' ? QueryThen<Result['value']['outputType']> : T['returnType'] extends 'rows' ? QueryThen<ColumnsShape.Output<Result>[keyof Result][][]> : T['returnType'] extends 'pluck' ? QueryThen<Result['pluck']['outputType'][]> : QueryThen<void>;
1704
- type QueryThenByReturnType<T extends QueryReturnType, Result extends Column.QueryColumns> = T extends undefined | 'all' ? QueryThenShallowSimplifyArr<ColumnsShape.Output<Result>> : T extends 'one' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<Result>> : T extends 'oneOrThrow' ? QueryThenShallowSimplify<ColumnsShape.Output<Result>> : T extends 'value' ? QueryThen<Result['value']['outputType'] | undefined> : T extends 'valueOrThrow' ? QueryThen<Result['value']['outputType']> : T extends 'rows' ? QueryThen<ColumnsShape.Output<Result>[keyof Result][][]> : T extends 'pluck' ? QueryThen<Result['pluck']['outputType'][]> : QueryThen<void>;
1984
+ type QueryThenByQuery<T extends PickQueryReturnType, Result extends Column.QueryColumns> = T['returnType'] extends undefined | 'all' ? QueryThenShallowSimplifyArr<ColumnsShape.Output<Result>> : T['returnType'] extends 'one' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<Result>> : T['returnType'] extends 'oneOrThrow' ? QueryThenShallowSimplify<ColumnsShape.Output<Result>> : T['returnType'] extends 'value' ? QueryThen<Result['value']['__outputType'] | undefined> : T['returnType'] extends 'valueOrThrow' ? QueryThen<Result['value']['__outputType']> : T['returnType'] extends 'rows' ? QueryThen<ColumnsShape.Output<Result>[keyof Result][][]> : T['returnType'] extends 'pluck' ? QueryThen<Result['pluck']['__outputType'][]> : QueryThen<void>;
1985
+ type QueryThenByReturnType<T extends QueryReturnType, Result extends Column.QueryColumns> = T extends undefined | 'all' ? QueryThenShallowSimplifyArr<ColumnsShape.Output<Result>> : T extends 'one' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<Result>> : T extends 'oneOrThrow' ? QueryThenShallowSimplify<ColumnsShape.Output<Result>> : T extends 'value' ? QueryThen<Result['value']['__outputType'] | undefined> : T extends 'valueOrThrow' ? QueryThen<Result['value']['__outputType']> : T extends 'rows' ? QueryThen<ColumnsShape.Output<Result>[keyof Result][][]> : T extends 'pluck' ? QueryThen<Result['pluck']['__outputType'][]> : QueryThen<void>;
1705
1986
  interface QueryCatch {
1706
1987
  <Q, TResult = never>(this: {
1707
1988
  then: (onfulfilled?: (value: Q) => any) => any;
@@ -2595,7 +2876,7 @@ declare namespace Order {
2595
2876
  export type Arg<T extends ArgThis> = ArgKey<T> | ArgTsQuery<T> | { [K in ArgKey<T> | ArgTsQuery<T>]?: K extends ArgTsQuery<T> ? OrderTsQueryConfig : SortDir } | Expression;
2596
2877
  export type Args<T extends ArgThis> = Arg<T>[];
2597
2878
  type ArgTsQuery<T extends ArgThis> = string | undefined extends T['__tsQuery'] ? never : Exclude<T['__tsQuery'], undefined>;
2598
- type ArgKey<T extends ArgThis> = { [K in keyof T['__selectable']]: T['__selectable'][K]['column']['queryType'] extends undefined ? never : K }[keyof T['__selectable']] | { [K in keyof T['result']]: T['result'][K]['dataType'] extends 'array' | 'object' | 'runtimeComputed' ? never : K }[keyof T['result']];
2879
+ type ArgKey<T extends ArgThis> = { [K in keyof T['__selectable']]: T['__selectable'][K]['column']['__queryType'] extends undefined ? never : K }[keyof T['__selectable']] | { [K in keyof T['result']]: T['result'][K]['dataType'] extends 'array' | 'object' | 'runtimeComputed' ? never : K }[keyof T['result']];
2599
2880
  export {};
2600
2881
  }
2601
2882
  declare class QueryOrder {
@@ -2701,40 +2982,40 @@ interface ColumnsShape {
2701
2982
  }
2702
2983
  declare namespace ColumnsShape {
2703
2984
  export type DefaultSelectKeys<S extends Column.QueryColumnsInit> = { [K in keyof S]: S[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof S];
2704
- export type DefaultOutput<Set extends Column.QueryColumnsInit> = { [K in DefaultSelectKeys<Set>]: Set[K]['outputType'] };
2705
- export type Input<Shape extends Column.QueryColumnsInit, AppReadOnly = { [K in keyof Shape]: Shape[K]['data']['appReadOnly'] extends true ? K : never }[keyof Shape], Optional extends keyof Shape = { [K in keyof Shape]: Shape[K]['data']['optional'] extends true ? K : never }[keyof Shape]> = { [K in Exclude<keyof Shape, AppReadOnly | Optional>]: Shape[K]['inputType'] } & { [K in Exclude<Optional, AppReadOnly>]?: Shape[K]['inputType'] };
2706
- export type InputPartial<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]?: Shape[K]['inputType'] };
2707
- export type Output<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['outputType'] };
2708
- export type DefaultSelectOutput<Shape extends Column.QueryColumnsInit> = { [K in { [K in keyof Shape]: Shape[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof Shape]]: Shape[K]['outputType'] };
2985
+ export type DefaultOutput<Set extends Column.QueryColumnsInit> = { [K in DefaultSelectKeys<Set>]: Set[K]['__outputType'] };
2986
+ export type Input<Shape extends Column.QueryColumnsInit, AppReadOnly = { [K in keyof Shape]: Shape[K]['data']['appReadOnly'] extends true ? K : never }[keyof Shape], Optional extends keyof Shape = { [K in keyof Shape]: Shape[K]['data']['optional'] extends true ? K : never }[keyof Shape]> = { [K in Exclude<keyof Shape, AppReadOnly | Optional>]: Shape[K]['__inputType'] } & { [K in Exclude<Optional, AppReadOnly>]?: Shape[K]['__inputType'] };
2987
+ export type InputPartial<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]?: Shape[K]['__inputType'] };
2988
+ export type Output<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['__outputType'] };
2989
+ export type DefaultSelectOutput<Shape extends Column.QueryColumnsInit> = { [K in { [K in keyof Shape]: Shape[K]['data']['explicitSelect'] extends true | undefined ? never : K }[keyof Shape]]: Shape[K]['__outputType'] };
2709
2990
  export interface MapToObjectColumn<Shape extends Column.QueryColumns> {
2710
2991
  dataType: 'object';
2711
- type: { [K in keyof Shape]: Shape[K]['type'] };
2712
- outputType: ShallowSimplify<ObjectOutput<Shape>>;
2713
- queryType: { [K in keyof Shape]: Shape[K]['queryType'] };
2992
+ __type: { [K in keyof Shape]: Shape[K]['__type'] };
2993
+ __outputType: ShallowSimplify<ObjectOutput<Shape>>;
2994
+ __queryType: { [K in keyof Shape]: Shape[K]['__queryType'] };
2714
2995
  operators: OperatorsAny;
2715
2996
  }
2716
2997
  export interface MapToNullableObjectColumn<Shape extends Column.QueryColumns> {
2717
2998
  dataType: 'object';
2718
- type: { [K in keyof Shape]: Shape[K]['type'] };
2719
- outputType: ShallowSimplify<ObjectOutput<Shape>> | undefined;
2720
- queryType: { [K in keyof Shape]: Shape[K]['queryType'] } | null;
2999
+ __type: { [K in keyof Shape]: Shape[K]['__type'] };
3000
+ __outputType: ShallowSimplify<ObjectOutput<Shape>> | undefined;
3001
+ __queryType: { [K in keyof Shape]: Shape[K]['__queryType'] } | null;
2721
3002
  operators: OperatorsAny;
2722
3003
  }
2723
3004
  export interface MapToPluckColumn<Shape extends Column.QueryColumns> {
2724
3005
  dataType: 'array';
2725
- type: Shape['pluck']['type'][];
2726
- outputType: Shape['pluck']['outputType'][];
2727
- queryType: Shape['pluck']['queryType'][];
3006
+ __type: Shape['pluck']['__type'][];
3007
+ __outputType: Shape['pluck']['__outputType'][];
3008
+ __queryType: Shape['pluck']['__queryType'][];
2728
3009
  operators: OperatorsAny;
2729
3010
  }
2730
3011
  export interface MapToObjectArrayColumn<Shape extends Column.QueryColumns> {
2731
3012
  dataType: 'array';
2732
- type: { [K in keyof Shape]: Shape[K]['type'] }[];
2733
- outputType: ShallowSimplify<ObjectOutput<Shape>>[];
2734
- queryType: { [K in keyof Shape]: Shape[K]['queryType'] }[];
3013
+ __type: { [K in keyof Shape]: Shape[K]['__type'] }[];
3014
+ __outputType: ShallowSimplify<ObjectOutput<Shape>>[];
3015
+ __queryType: { [K in keyof Shape]: Shape[K]['__queryType'] }[];
2735
3016
  operators: OperatorsAny;
2736
3017
  }
2737
- type ObjectOutput<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['outputType'] };
3018
+ type ObjectOutput<Shape extends Column.QueryColumns> = { [K in keyof Shape]: Shape[K]['__outputType'] };
2738
3019
  export {};
2739
3020
  }
2740
3021
  interface SelectSelf extends PickQuerySelectable, PickQueryHasSelect, PickQueryDefaultSelect, PickQueryShape, PickQueryRelations, PickQueryResult, PickQueryReturnType, PickQueryWithData {}
@@ -3162,16 +3443,16 @@ interface OperatorsCount extends OperatorsNumber {
3162
3443
  type CountColumn = Column.Pick.QueryColumnOfTypeAndOps<'int8', number, OperatorsCount>;
3163
3444
  type CountReturn<T> = SetQueryReturnsColumnOrThrow<T, CountColumn> & OperatorsCount;
3164
3445
  type SelectableDataType<T extends PickQuerySelectable, DataType extends string> = { [K in keyof T['__selectable']]: T['__selectable'][K]['column']['dataType'] extends DataType ? K : never }[keyof T['__selectable']] | Expression<Column.Pick.QueryColumnOfDataType<DataType>>;
3165
- type NumericReturn<T extends PickQuerySelectable, Arg> = Arg extends keyof T['__selectable'] ? SetQueryReturnsColumnOrThrow<T, Column.Pick.QueryColumnOfTypeAndOps<T['__selectable'][Arg]['column']['dataType'], T['__selectable'][Arg]['column']['type'] | null, OperatorsNumber>> & OperatorsNumber : Arg extends Expression ? SetQueryReturnsColumnOrThrow<T, Column.Pick.QueryColumnOfTypeAndOps<Arg['result']['value']['dataType'], Arg['result']['value']['type'] | null, OperatorsNumber>> & OperatorsNumber : never;
3446
+ type NumericReturn<T extends PickQuerySelectable, Arg> = Arg extends keyof T['__selectable'] ? SetQueryReturnsColumnOrThrow<T, Column.Pick.QueryColumnOfTypeAndOps<T['__selectable'][Arg]['column']['dataType'], T['__selectable'][Arg]['column']['__type'] | null, OperatorsNumber>> & OperatorsNumber : Arg extends Expression ? SetQueryReturnsColumnOrThrow<T, Column.Pick.QueryColumnOfTypeAndOps<Arg['result']['value']['dataType'], Arg['result']['value']['__type'] | null, OperatorsNumber>> & OperatorsNumber : never;
3166
3447
  type NullableNumberReturn<T, DataType> = SetQueryReturnsColumnOrThrow<T, Column.Pick.QueryColumnOfTypeAndOps<DataType, number | null, OperatorsNumber>> & OperatorsNumber;
3167
3448
  type BooleanQueryColumn = Column.Pick.QueryColumnOfTypeAndOps<'bool', boolean, OperatorsBoolean>;
3168
3449
  type BooleanNullable = Column.Pick.QueryColumnOfTypeAndOps<'bool', boolean | null, OperatorsBoolean>;
3169
3450
  type NullableBooleanReturn<T> = SetQueryReturnsColumnOrThrow<T, BooleanNullable> & OperatorsBoolean;
3170
3451
  type NullableJSONAggReturn<T extends PickQuerySelectable, Arg extends SelectableOrExpression<T>> = SetQueryReturnsColumnOrThrow<T, {
3171
3452
  dataType: 'json';
3172
- type: (ExpressionOutput<T, Arg>['type'] | null)[] | null;
3173
- outputType: (ExpressionOutput<T, Arg>['outputType'] | null)[] | null;
3174
- queryType: (ExpressionOutput<T, Arg>['queryType'] | null)[] | null;
3453
+ __type: (ExpressionOutput<T, Arg>['__type'] | null)[] | null;
3454
+ __outputType: (ExpressionOutput<T, Arg>['__outputType'] | null)[] | null;
3455
+ __queryType: (ExpressionOutput<T, Arg>['__queryType'] | null)[] | null;
3175
3456
  operators: OperatorsArray<never>;
3176
3457
  }> & OperatorsArray<never>;
3177
3458
  interface RecordSelectableOrExpression<T extends PickQuerySelectable> {
@@ -3179,9 +3460,9 @@ interface RecordSelectableOrExpression<T extends PickQuerySelectable> {
3179
3460
  }
3180
3461
  type NullableJSONObjectReturn<T extends PickQuerySelectable, Obj extends RecordSelectableOrExpression<T>> = SetQueryReturnsColumnOrThrow<T, {
3181
3462
  dataType: 'json';
3182
- type: { [K in keyof Obj]: ExpressionOutput<T, Obj[K]>['type'] } | null;
3183
- outputType: { [K in keyof Obj]: ExpressionOutput<T, Obj[K]>['outputType'] } | null;
3184
- queryType: { [K in keyof Obj]: ExpressionOutput<T, Obj[K]>['queryType'] } | null;
3463
+ __type: { [K in keyof Obj]: ExpressionOutput<T, Obj[K]>['__type'] } | null;
3464
+ __outputType: { [K in keyof Obj]: ExpressionOutput<T, Obj[K]>['__outputType'] } | null;
3465
+ __queryType: { [K in keyof Obj]: ExpressionOutput<T, Obj[K]>['__queryType'] } | null;
3185
3466
  operators: OperatorsAny;
3186
3467
  }> & OperatorsAny;
3187
3468
  type StringColumn$1 = Column.Pick.QueryColumnOfTypeAndOps<string, string, OperatorsText>;
@@ -3618,11 +3899,11 @@ declare class OrExpression extends Expression<BooleanQueryColumn> {
3618
3899
  interface QueryReturnsFnAdd<T extends PickQueryColumTypes> extends PickQueryHasSelect {
3619
3900
  type<C extends Column.Pick.QueryColumn>(fn: (types: T['columnTypes']) => C): { [K in keyof T]: K extends 'result' ? {
3620
3901
  value: C;
3621
- } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<C['outputType']> : T[K] } & C['operators'];
3902
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<C['__outputType']> : T[K] } & C['operators'];
3622
3903
  }
3623
3904
  type SetQueryReturnsFn<T extends PickQueryColumTypes, C extends Column.Pick.OutputType> = { [K in keyof T]: K extends 'result' ? {
3624
3905
  value: C;
3625
- } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<C['outputType']> : T[K] } & QueryReturnsFnAdd<T>;
3906
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<C['__outputType']> : T[K] } & QueryReturnsFnAdd<T>;
3626
3907
  declare class QueryExpressions {
3627
3908
  /**
3628
3909
  * `column` references a table column, this can be used in raw SQL or when building a column expression.
@@ -3715,16 +3996,16 @@ declare class QueryExpressions {
3715
3996
  type WhereArg<T extends PickQuerySelectableRelations> = { [K in keyof T['__selectable'] | 'NOT' | 'OR' | 'IN']?: K extends 'NOT' ? WhereArg<T> | WhereArgs<T> : K extends 'OR' ? (WhereArg<T> | WhereArgs<T>)[] : K extends 'IN' ? MaybeArray<{
3716
3997
  columns: (keyof T['__selectable'])[];
3717
3998
  values: unknown[][] | IsQuery | Expression;
3718
- }> : T['__selectable'][K]['column']['queryType'] | null | { [O in keyof T['__selectable'][K]['column']['operators']]?: T['__selectable'][K]['column']['operators'][O]['_opType'] } | {
3999
+ }> : T['__selectable'][K]['column']['__queryType'] | null | { [O in keyof T['__selectable'][K]['column']['operators']]?: T['__selectable'][K]['column']['operators'][O]['_opType'] } | {
3719
4000
  result: {
3720
4001
  value: {
3721
- queryType: T['__selectable'][K]['column']['queryType'] | null;
4002
+ __queryType: T['__selectable'][K]['column']['__queryType'] | null;
3722
4003
  };
3723
4004
  };
3724
4005
  } | ((q: T) => {
3725
4006
  result: {
3726
4007
  value: {
3727
- queryType: T['__selectable'][K]['column']['queryType'] | null;
4008
+ __queryType: T['__selectable'][K]['column']['__queryType'] | null;
3728
4009
  };
3729
4010
  };
3730
4011
  }) } | ((q: WhereQueryBuilder<T>) => QueryOrExpressionBooleanOrNullResult | WhereQueryBuilder<T>);
@@ -3740,12 +4021,12 @@ type WhereQueryBuilder<T extends PickQueryRelations> = EmptyObject extends T['re
3740
4021
  type WhereArgs<T extends PickQuerySelectableRelations> = WhereArg<T>[];
3741
4022
  type WhereNotArgs<T extends PickQuerySelectableRelations> = [WhereArg<T>];
3742
4023
  type WhereInColumn<T extends PickQuerySelectableRelations> = keyof T['__selectable'] | [keyof T['__selectable'], ...(keyof T['__selectable'])[]];
3743
- type WhereInValues<T extends PickQuerySelectableRelations, Column> = Column extends keyof T['__selectable'] ? Iterable<T['__selectable'][Column]['column']['queryType']> | IsQuery | Expression : ({ [I in keyof Column]: Column[I] extends keyof T['__selectable'] ? T['__selectable'][Column[I]]['column']['queryType'] : never } & {
4024
+ type WhereInValues<T extends PickQuerySelectableRelations, Column> = Column extends keyof T['__selectable'] ? Iterable<T['__selectable'][Column]['column']['__queryType']> | IsQuery | Expression : ({ [I in keyof Column]: Column[I] extends keyof T['__selectable'] ? T['__selectable'][Column[I]]['column']['__queryType'] : never } & {
3744
4025
  length: Column extends {
3745
4026
  length: number;
3746
4027
  } ? Column['length'] : never;
3747
4028
  })[] | IsQuery | Expression;
3748
- type WhereInArg<T extends PickQuerySelectableRelations> = { [K in keyof T['__selectable']]?: Iterable<T['__selectable'][K]['column']['queryType']> | IsQuery | Expression };
4029
+ type WhereInArg<T extends PickQuerySelectableRelations> = { [K in keyof T['__selectable']]?: Iterable<T['__selectable'][K]['column']['__queryType']> | IsQuery | Expression };
3749
4030
  interface QueryHasWhere {
3750
4031
  __hasWhere: true;
3751
4032
  }
@@ -4858,8 +5139,8 @@ interface QueryInternal<SinglePrimaryKey = any, UniqueColumns = any, UniqueColum
4858
5139
  */
4859
5140
  nestedCreateBatchMax: number;
4860
5141
  }
4861
- type ShapeColumnPrimaryKeys<Shape extends Column.QueryColumnsInit> = { [K in { [K in keyof Shape]: Shape[K]['data']['primaryKey'] extends string ? K : never }[keyof Shape]]: UniqueQueryTypeOrExpression<Shape[K]['queryType']> };
4862
- type ShapeUniqueColumns<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]: Shape[K]['data']['unique'] extends string ? { [C in K]: UniqueQueryTypeOrExpression<Shape[K]['queryType']> } : never }[keyof Shape];
5142
+ type ShapeColumnPrimaryKeys<Shape extends Column.QueryColumnsInit> = { [K in { [K in keyof Shape]: Shape[K]['data']['primaryKey'] extends string ? K : never }[keyof Shape]]: UniqueQueryTypeOrExpression<Shape[K]['__queryType']> };
5143
+ type ShapeUniqueColumns<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]: Shape[K]['data']['unique'] extends string ? { [C in K]: UniqueQueryTypeOrExpression<Shape[K]['__queryType']> } : never }[keyof Shape];
4863
5144
  type UniqueConstraints<Shape extends Column.QueryColumnsInit> = { [K in keyof Shape]: Shape[K]['data']['primaryKey'] extends string ? string extends Shape[K]['data']['primaryKey'] ? never : Shape[K]['data']['primaryKey'] : Shape[K]['data']['unique'] extends string ? string extends Shape[K]['data']['unique'] ? never : Shape[K]['data']['unique'] : never }[keyof Shape];
4864
5145
  type NoPrimaryKeyOption = 'error' | 'warning' | 'ignore';
4865
5146
  interface DbSharedOptions extends QueryLogOptions {
@@ -4965,13 +5246,15 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Col
4965
5246
  __defaultSelect: DefaultSelect;
4966
5247
  baseQuery: Query;
4967
5248
  columns: (keyof Shape)[];
4968
- outputType: ColumnsShape.DefaultSelectOutput<Shape>;
4969
- inputType: ColumnsShape.Input<Shape>;
5249
+ __outputType: ColumnsShape.DefaultSelectOutput<Shape>;
5250
+ __inputType: ColumnsShape.Input<Shape>;
4970
5251
  result: { [K in DefaultSelect]: Shape[K] };
4971
5252
  returnType: undefined;
4972
5253
  then: QueryThenShallowSimplifyArr<ColumnsShape.DefaultOutput<Shape>>;
4973
5254
  windows: EmptyObject;
4974
5255
  relations: EmptyObject;
5256
+ relationsDataForCreate: EmptyObject;
5257
+ relationsDataForCreateOptional: EmptyObject;
4975
5258
  relationQueries: EmptyObject;
4976
5259
  withData: EmptyObject;
4977
5260
  error: new (message: string, length: number, name: QueryErrorName) => QueryError<this>;
@@ -5052,6 +5335,7 @@ interface DbTableConstructor<ColumnTypes> {
5052
5335
  interface DbSqlMethod<ColumnTypes> {
5053
5336
  <T>(...args: StaticSQLArgs): RawSql<Column.Pick.QueryColumnOfType<T>, ColumnTypes>;
5054
5337
  <T>(...args: [DynamicSQLArg<Column.Pick.QueryColumnOfType<T>>]): DynamicRawSQL<Column.Pick.QueryColumnOfType<T>, ColumnTypes>;
5338
+ join<T = unknown>(items: readonly unknown[], separator?: RawSqlBase): SqlJoinExpression<Column.Pick.QueryColumnOfType<T>>;
5055
5339
  ref(name: string): SqlRefExpression;
5056
5340
  unsafe(sql: string | number | boolean): UnsafeSqlExpression;
5057
5341
  }
@@ -5064,7 +5348,7 @@ type MapTableScopesOption<T> = T extends {
5064
5348
  } ? {
5065
5349
  nonDeleted: unknown;
5066
5350
  } : EmptyObject;
5067
- interface DbResult<ColumnTypes> extends Db<string, never, never, never, never, never, ColumnTypes>, DbTableConstructor<ColumnTypes> {
5351
+ interface DbResult<ColumnTypes> extends Db<undefined, EmptyObject, never, never, never, never, ColumnTypes, never, never>, DbTableConstructor<ColumnTypes> {
5068
5352
  adapterNotInTransaction: Adapter;
5069
5353
  adapter: Adapter;
5070
5354
  close: Adapter['close'];
@@ -5261,6 +5545,37 @@ declare function raw<T = never>(...args: StaticSQLArgs): RawSql<Column.Pick.Quer
5261
5545
  declare function raw<T = never>(...args: [DynamicSQLArg<Column.Pick.QueryColumnOfType<T>>]): DynamicRawSQL<Column.Pick.QueryColumnOfType<T>>;
5262
5546
  interface SqlFn {
5263
5547
  <T, Args extends TemplateLiteralArgs | [sql: string] | [values: RecordUnknown, sql?: string]>(this: T, ...args: Args): Args extends [RecordUnknown] ? (...sql: TemplateLiteralArgs) => RawSql<Column.Pick.QueryColumn, T> : RawSql<Column.Pick.QueryColumn, T>;
5548
+ /**
5549
+ * `sql.join` builds a SQL list from values and expressions.
5550
+ * Plain values are bound as query parameters, while SQL expressions render as SQL.
5551
+ *
5552
+ * Use it for SQL constructs such as `ARRAY[...]`, `IN (...)`, function arguments,
5553
+ * or tuple lists. The default separator is `, `. Provide a SQL expression as the
5554
+ * custom separator when a different separator is needed.
5555
+ *
5556
+ * ```ts
5557
+ * await db.user.whereSql`"id" IN (${sql.join([1, 2, 3])})`;
5558
+ * ```
5559
+ *
5560
+ * ```ts
5561
+ * await db.user.whereSql`
5562
+ * (${sql.join([sql.ref('name'), sql.ref('age')])}) IN (${sql.join(
5563
+ * users.map((user) => sql`(${user.name}, ${user.age})`),
5564
+ * )})
5565
+ * `;
5566
+ * ```
5567
+ *
5568
+ * ```ts
5569
+ * await db.user.select({
5570
+ * displayName: (q) =>
5571
+ * sql<string>`concat(${sql.join(
5572
+ * [q.column('firstName'), q.column('lastName')],
5573
+ * sql` || ' ' || `,
5574
+ * )})`,
5575
+ * });
5576
+ * ```
5577
+ */
5578
+ join<T = unknown>(items: readonly unknown[], separator?: RawSqlBase): SqlJoinExpression<Column.Pick.QueryColumnOfType<T>>;
5264
5579
  /**
5265
5580
  * `sql.ref` quotes a SQL identifier such as a table name, column name, or schema name.
5266
5581
  * Use it when you need to dynamically reference an identifier in raw SQL.
@@ -5513,7 +5828,7 @@ interface OperatorToSQL {
5513
5828
  interface Operator<Value, Column extends Column.Pick.OutputTypeAndOperators = Column.Pick.OutputTypeAndOperators> {
5514
5829
  <T extends PickQueryResult>(this: T, arg: Value): { [K in Exclude<keyof T, keyof T['result']['value']['operators']>]: K extends 'result' ? {
5515
5830
  value: Column;
5516
- } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Column['outputType']> : T[K] } & Column['operators'];
5831
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Column['__outputType']> : T[K] } & Column['operators'];
5517
5832
  _opType: Value;
5518
5833
  }
5519
5834
  interface Base$1<Value> {
@@ -6124,7 +6439,7 @@ interface SelectAsValue {
6124
6439
  [K: string]: string | Query | Expression | undefined;
6125
6440
  }
6126
6441
  declare const getShapeFromSelect: (q: IsQuery, isSubQuery?: boolean) => Column.QueryColumns;
6127
- type AfterHook<Select extends PropertyKey[], Shape extends Column.QueryColumns> = QueryAfterHook<{ [K in Select[number]]: K extends keyof Shape ? Shape[K]['outputType'] : never }[]>;
6442
+ type AfterHook<Select extends PropertyKey[], Shape extends Column.QueryColumns> = QueryAfterHook<{ [K in Select[number]]: K extends keyof Shape ? Shape[K]['__outputType'] : never }[]>;
6128
6443
  type HookSelectArg<T extends PickQueryShape> = (keyof T['shape'] & string)[];
6129
6444
  declare const _hookSelectColumns: (query: Query, columns: string[], asFn: (as: string[]) => void) => void;
6130
6445
  declare class QueryHookUtils<T extends PickQueryInputType> {
@@ -6132,7 +6447,7 @@ declare class QueryHookUtils<T extends PickQueryInputType> {
6132
6447
  columns: string[];
6133
6448
  private key;
6134
6449
  constructor(query: IsQuery, columns: string[], key: 'hookCreateSet' | 'hookUpdateSet');
6135
- set: (data: { [K in keyof T["inputType"]]?: T["inputType"][K] | (() => QueryOrExpression<T["inputType"][K]>) }) => void;
6450
+ set: (data: { [K in keyof T["__inputType"]]?: T["__inputType"][K] | (() => QueryOrExpression<T["__inputType"][K]>) }) => void;
6136
6451
  }
6137
6452
  declare const _queryHookAfterCreate: <T extends PickQueryShape, S extends HookSelectArg<T>>(q: T, select: S, cb: AfterHook<S, T["shape"]>) => T;
6138
6453
  declare const _queryHookAfterUpdate: <T extends PickQueryShape, S extends HookSelectArg<T>>(q: T, select: S, cb: AfterHook<S, T["shape"]>) => T;
@@ -6285,7 +6600,7 @@ interface ColumnDataSelectSqlProp {
6285
6600
  interface SelectSqlCallback {
6286
6601
  (column: ColumnRefExpression<Column.Pick.QueryColumn>): Expression;
6287
6602
  }
6288
- type SelectSqlColumn<T extends Column.Pick.DataAndDataType, Expr extends Expression> = unknown extends Expr['result']['value']['outputType'] ? T : { [K in keyof T]: K extends 'outputType' ? Expr['result']['value']['outputType'] : T[K] };
6603
+ type SelectSqlColumn<T extends Column.Pick.DataAndDataType, Expr extends Expression> = unknown extends Expr['result']['value']['__outputType'] ? T : { [K in keyof T]: K extends '__outputType' ? Expr['result']['value']['__outputType'] : T[K] };
6289
6604
  declare namespace Column {
6290
6605
  export namespace Modifiers {
6291
6606
  export interface IsPrimaryKey<Name extends string> {
@@ -6298,9 +6613,9 @@ declare namespace Column {
6298
6613
  unique: Name;
6299
6614
  };
6300
6615
  };
6301
- export type Nullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends 'type' ? T['type'] | null : K extends 'inputType' ? T['inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends 'outputType' ? T['outputType'] | (unknown extends T['nullType'] ? null : T['nullType']) : K extends 'outputSchema' ? OutputSchema : K extends 'queryType' ? T['queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' ? Operator<T | null> : T['operators'][K] } : T[K] };
6302
- export type QueryColumnToNullable<C> = { [K in keyof C]: K extends 'outputType' | 'queryType' ? C[K] | null : C[K] };
6303
- export type QueryColumnToOptional<C> = { [K in keyof C]: K extends 'outputType' ? C[K] | undefined : C[K] };
6616
+ export type Nullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' ? Operator<T | null> : T['operators'][K] } : T[K] };
6617
+ export type QueryColumnToNullable<C> = { [K in keyof C]: K extends '__outputType' | '__queryType' ? C[K] | null : C[K] };
6618
+ export type QueryColumnToOptional<C> = { [K in keyof C]: K extends '__outputType' ? C[K] | undefined : C[K] };
6304
6619
  interface DataNullable {
6305
6620
  isNullable: true;
6306
6621
  optional: true;
@@ -6309,9 +6624,9 @@ declare namespace Column {
6309
6624
  equals: Operator<T | null>;
6310
6625
  not: Operator<T | null>;
6311
6626
  }
6312
- export type Encode<T, InputSchema, Input> = { [K in keyof T]: K extends 'inputType' ? Input : K extends 'inputSchema' ? InputSchema : T[K] };
6313
- export type Parse<T extends Pick.ForParse, OutputSchema, Output> = { [K in keyof T]: K extends 'outputType' ? null extends T['type'] ? (Output extends null ? never : Output) | (unknown extends T['nullType'] ? null : T['nullType']) : Output : K extends 'outputSchema' ? null extends T['type'] ? OutputSchema | T['nullSchema'] : OutputSchema : T[K] };
6314
- export type ParseNull<T extends Column.Pick.ForParseNull, NullSchema, NullType> = { [K in keyof T]: K extends 'outputType' ? null extends T['type'] ? Exclude<T['outputType'], null> | NullType : T['outputType'] : K extends 'nullType' ? NullType : K extends 'outputSchema' ? null extends T['type'] ? T['outputSchema'] | NullSchema : T['outputSchema'] : K extends 'nullSchema' ? NullSchema : T[K] };
6627
+ export type Encode<T, InputSchema, Input> = { [K in keyof T]: K extends '__inputType' ? Input : K extends 'inputSchema' ? InputSchema : T[K] };
6628
+ export type Parse<T extends Pick.ForParse, OutputSchema, Output> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? (Output extends null ? never : Output) | (unknown extends T['__nullType'] ? null : T['__nullType']) : Output : K extends 'outputSchema' ? null extends T['__type'] ? OutputSchema | T['nullSchema'] : OutputSchema : T[K] };
6629
+ export type ParseNull<T extends Column.Pick.ForParseNull, NullSchema, NullType> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? Exclude<T['__outputType'], null> | NullType : T['__outputType'] : K extends '__nullType' ? NullType : K extends 'outputSchema' ? null extends T['__type'] ? T['outputSchema'] | NullSchema : T['outputSchema'] : K extends 'nullSchema' ? NullSchema : T[K] };
6315
6630
  type DefaultData<T extends Column.Data, Value> = { [K in keyof T]: K extends 'default' ? Value extends null ? never : Value : K extends 'optional' ? true : T[K] };
6316
6631
  export type Default<T extends Column.Pick.Data, Value> = { [K in keyof T]: K extends 'data' ? DefaultData<T['data'], Value> : T[K] };
6317
6632
  type DefaultSelectData<T extends Column.Data, Value> = { [K in keyof T]: K extends 'explicitSelect' ? Value extends true ? false : true : T[K] };
@@ -6321,7 +6636,7 @@ declare namespace Column {
6321
6636
  appReadOnly: true;
6322
6637
  };
6323
6638
  }
6324
- export type Generated<T extends Column.Pick.Data> = { [K in keyof T]: K extends 'data' ? { [K in keyof T['data']]: K extends 'default' ? true : T['data'][K] } : K extends 'inputType' ? never : T[K] };
6639
+ export type Generated<T extends Column.Pick.Data> = { [K in keyof T]: K extends 'data' ? { [K in keyof T['data']]: K extends 'default' ? true : T['data'][K] } : K extends '__inputType' ? never : T[K] };
6325
6640
  export {};
6326
6641
  }
6327
6642
  export namespace Pick {
@@ -6329,17 +6644,17 @@ declare namespace Column {
6329
6644
  data: Column.Data;
6330
6645
  }
6331
6646
  interface Type {
6332
- type: unknown;
6647
+ __type: unknown;
6333
6648
  }
6334
6649
  interface OutputType {
6335
- outputType: unknown;
6650
+ __outputType: unknown;
6336
6651
  }
6337
6652
  interface InputType {
6338
- inputType: unknown;
6653
+ __inputType: unknown;
6339
6654
  }
6340
6655
  interface DataAndInputType extends Data, InputType {}
6341
6656
  interface NullType {
6342
- nullType: unknown;
6657
+ __nullType: unknown;
6343
6658
  }
6344
6659
  interface OutputTypeAndOperators extends OutputType {
6345
6660
  operators: unknown;
@@ -6349,22 +6664,22 @@ declare namespace Column {
6349
6664
  }
6350
6665
  interface QueryColumn extends OutputType {
6351
6666
  dataType: string;
6352
- type: unknown;
6353
- queryType: unknown;
6667
+ __type: unknown;
6668
+ __queryType: unknown;
6354
6669
  operators: any;
6355
6670
  }
6356
6671
  interface QueryColumnOfType<T> {
6357
6672
  dataType: string;
6358
- type: T;
6359
- outputType: T;
6360
- queryType: T;
6673
+ __type: T;
6674
+ __outputType: T;
6675
+ __queryType: T;
6361
6676
  operators: any;
6362
6677
  }
6363
6678
  interface QueryColumnOfTypeAndOps<DataType, T, Ops> {
6364
6679
  dataType: DataType;
6365
- type: T;
6366
- outputType: T;
6367
- queryType: T;
6680
+ __type: T;
6681
+ __outputType: T;
6682
+ __queryType: T;
6368
6683
  operators: Ops;
6369
6684
  }
6370
6685
  interface QueryColumnOfDataType<T extends string> extends QueryColumn {
@@ -6384,8 +6699,8 @@ declare namespace Column {
6384
6699
  querySchema: any;
6385
6700
  }
6386
6701
  interface ForNullable extends Data, Type, InputType, OutputType, TypeSchemas {
6387
- nullType: unknown;
6388
- queryType: unknown;
6702
+ __nullType: unknown;
6703
+ __queryType: unknown;
6389
6704
  operators: unknown;
6390
6705
  }
6391
6706
  interface ForParse extends Type, NullType, NullSchema {}
@@ -6435,9 +6750,9 @@ declare namespace Column {
6435
6750
  type StringOrMessage = string | Message;
6436
6751
  }
6437
6752
  export interface InputOutputQueryTypes {
6438
- inputType: unknown;
6439
- outputType: unknown;
6440
- queryType: unknown;
6753
+ __inputType: unknown;
6754
+ __outputType: unknown;
6755
+ __queryType: unknown;
6441
6756
  }
6442
6757
  export interface InputOutputQueryTypesWithSchemas extends InputOutputQueryTypes {
6443
6758
  inputSchema: unknown;
@@ -6534,24 +6849,24 @@ declare const setDataValue: <T extends Column.Pick.Data, Key extends string, Val
6534
6849
  declare function setCurrentColumnName(name: string): void;
6535
6850
  declare const consumeColumnName: () => string | undefined;
6536
6851
  declare const setDefaultLanguage: (lang?: string) => void;
6537
- declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSchemaArg, Type = unknown, InputSchema = any, Ops = any, InputType = Type, OutputType = Type, OutputSchema = InputSchema, QueryType = InputType, QuerySchema = InputSchema> {
6538
- inputSchema: InputSchema;
6539
- outputSchema: OutputSchema;
6540
- querySchema: QuerySchema;
6852
+ declare abstract class Column {
6853
+ abstract __schema: ColumnTypeSchemaArg;
6541
6854
  abstract dataType: string;
6542
- abstract operators: Ops;
6855
+ abstract operators: any;
6543
6856
  abstract toCode(ctx: ColumnToCodeCtx, key: string): Code;
6544
- type: Type;
6545
- inputType: InputType;
6546
- outputType: OutputType;
6547
- queryType: QueryType;
6548
- nullType: unknown;
6857
+ abstract __type: unknown;
6858
+ abstract __inputType: unknown;
6859
+ abstract __outputType: unknown;
6860
+ abstract __queryType: unknown;
6861
+ __nullType: unknown;
6549
6862
  nullSchema: unknown;
6550
- isNullable: boolean;
6863
+ abstract inputSchema: unknown;
6864
+ abstract outputSchema: unknown;
6865
+ abstract querySchema: unknown;
6551
6866
  data: Column.Data;
6552
- error: Schema['error'];
6867
+ error: this['__schema']['error'];
6553
6868
  _parse?: (input: unknown) => unknown;
6554
- constructor(schema: ColumnTypeSchemaArg, inputSchema: InputSchema, outputSchema?: OutputSchema, querySchema?: QuerySchema);
6869
+ constructor(schema: ColumnTypeSchemaArg, inputSchema: unknown, outputSchema?: unknown, querySchema?: unknown);
6555
6870
  /**
6556
6871
  * Set a default value to a column. Columns that have defaults become optional when creating a record.
6557
6872
  *
@@ -6578,7 +6893,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6578
6893
  *
6579
6894
  * @param value - default value or a function returning a value
6580
6895
  */
6581
- default<T extends Column.Pick.DataAndInputType, Value extends T['inputType'] | null | RawSqlBase | (() => T['inputType'])>(this: T, value: Value): Column.Modifiers.Default<T, Value>;
6896
+ default<T extends Column.Pick.DataAndInputType, Value extends T['__inputType'] | null | RawSqlBase | (() => T['__inputType'])>(this: T, value: Value): Column.Modifiers.Default<T, Value>;
6582
6897
  /**
6583
6898
  * Use `hasDefault` to let the column be omitted when creating records.
6584
6899
  *
@@ -6624,7 +6939,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6624
6939
  * }
6625
6940
  * ```
6626
6941
  */
6627
- nullable: Schema['nullable'];
6942
+ nullable: this['__schema']['nullable'];
6628
6943
  /**
6629
6944
  * Set a custom function to process value for the column when creating or updating a record.
6630
6945
  *
@@ -6660,7 +6975,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6660
6975
  *
6661
6976
  * @param fn - function to encode value for a database, argument type is specified by you, return type must be compatible with a database
6662
6977
  */
6663
- encode: Schema['encode'];
6978
+ encode: this['__schema']['encode'];
6664
6979
  /**
6665
6980
  * Set a custom function to process value after loading it from a database.
6666
6981
  *
@@ -6698,7 +7013,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6698
7013
  *
6699
7014
  * @param fn - function to parse a value from the database, argument is the type of this column, return type is up to you
6700
7015
  */
6701
- parse: Schema['parse'];
7016
+ parse: this['__schema']['parse'];
6702
7017
  /**
6703
7018
  * Use `parseNull` to specify runtime defaults at selection time.
6704
7019
  *
@@ -6743,7 +7058,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6743
7058
  * })
6744
7059
  * ```
6745
7060
  */
6746
- parseNull: Schema['parseNull'];
7061
+ parseNull: this['__schema']['parseNull'];
6747
7062
  /**
6748
7063
  * This method changes a column type without modifying its behavior.
6749
7064
  * This is needed when converting columns to a validation schema, the converter will pick a different type specified by `.as`.
@@ -6763,17 +7078,17 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6763
7078
  * @param column - other column type to inherit from
6764
7079
  */
6765
7080
  as<T extends {
6766
- inputType: unknown;
6767
- outputType: unknown;
7081
+ __inputType: unknown;
7082
+ __outputType: unknown;
6768
7083
  data: Column.Data;
6769
7084
  }, C extends {
6770
- inputType: T['inputType'];
6771
- outputType: T['outputType'];
7085
+ __inputType: T['__inputType'];
7086
+ __outputType: T['__outputType'];
6772
7087
  }>(this: T, column: C): C;
6773
7088
  /**
6774
7089
  * @deprecated use narrowType instead
6775
7090
  */
6776
- asType: Schema['asType'];
7091
+ asType: this['__schema']['asType'];
6777
7092
  /**
6778
7093
  * `narrowType` narrows TypeScript types of a column. It sets input, output, query type altogether.
6779
7094
  *
@@ -6816,8 +7131,10 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6816
7131
  * // size will be typed as 'small' | 'medium' | 'large'
6817
7132
  * const size = await db.table.get('size');
6818
7133
  * ```
7134
+ *
7135
+ * @deprecated use `type` instead
6819
7136
  */
6820
- narrowType: Schema['narrowType'];
7137
+ narrowType: this['__schema']['narrowType'];
6821
7138
  /**
6822
7139
  * Allows to narrow different TypeScript types of a column granularly.
6823
7140
  *
@@ -6873,17 +7190,19 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6873
7190
  * // size will be typed as 'small' | 'medium' | 'large'
6874
7191
  * const size = await db.table.get('size');
6875
7192
  * ```
7193
+ *
7194
+ * @deprecated use `type`, `inputType`, `outputType`, `queryType` instead
6876
7195
  */
6877
- narrowAllTypes: Schema['narrowAllTypes'];
7196
+ narrowAllTypes: this['__schema']['narrowAllTypes'];
6878
7197
  input<T extends {
6879
7198
  inputSchema: unknown;
6880
- }, InputSchema extends Schema['type']>(this: T, fn: (schema: T['inputSchema']) => InputSchema): { [K in keyof T]: K extends 'inputSchema' ? InputSchema : T[K] };
7199
+ }, InputSchema extends this['__schema']['__schemaType']>(this: T, fn: (schema: T['inputSchema']) => InputSchema): { [K in keyof T]: K extends 'inputSchema' ? InputSchema : T[K] };
6881
7200
  output<T extends {
6882
7201
  outputSchema: unknown;
6883
- }, OutputSchema extends Schema['type']>(this: T, fn: (schema: T['outputSchema']) => OutputSchema): { [K in keyof T]: K extends 'outputSchema' ? OutputSchema : T[K] };
7202
+ }, OutputSchema extends this['__schema']['__schemaType']>(this: T, fn: (schema: T['outputSchema']) => OutputSchema): { [K in keyof T]: K extends 'outputSchema' ? OutputSchema : T[K] };
6884
7203
  query<T extends {
6885
7204
  querySchema: unknown;
6886
- }, QuerySchema extends Schema['type']>(this: T, fn: (schema: T['querySchema']) => QuerySchema): { [K in keyof T]: K extends 'querySchema' ? QuerySchema : T[K] };
7205
+ }, QuerySchema extends this['__schema']['__schemaType']>(this: T, fn: (schema: T['querySchema']) => QuerySchema): { [K in keyof T]: K extends 'querySchema' ? QuerySchema : T[K] };
6887
7206
  /**
6888
7207
  * Set a database column name.
6889
7208
  *
@@ -6977,7 +7296,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6977
7296
  * }
6978
7297
  * ```
6979
7298
  */
6980
- setOnCreate<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['inputType'] | void): T;
7299
+ setOnCreate<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['__inputType'] | void): T;
6981
7300
  /**
6982
7301
  * Set a column value when updating a record.
6983
7302
  * This works for [readOnly](#readonly) columns as well.
@@ -6994,7 +7313,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
6994
7313
  * }
6995
7314
  * ```
6996
7315
  */
6997
- setOnUpdate<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['inputType'] | void): T;
7316
+ setOnUpdate<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['__inputType'] | void): T;
6998
7317
  /**
6999
7318
  * Set a column value when creating or updating a record.
7000
7319
  * This works for [readOnly](#readonly) columns as well.
@@ -7011,7 +7330,7 @@ declare abstract class Column<Schema extends ColumnTypeSchemaArg = ColumnTypeSch
7011
7330
  * }
7012
7331
  * ```
7013
7332
  */
7014
- setOnSave<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['inputType'] | void): T;
7333
+ setOnSave<T extends Column.Pick.QueryInit>(this: T, fn: (arg: QueryHookUtils<PickQueryInputType>) => T['__inputType'] | void): T;
7015
7334
  /**
7016
7335
  * Mark the column as a primary key.
7017
7336
  * This column type becomes an argument of the `.find` method.
@@ -7529,13 +7848,14 @@ declare class QueryCreateFrom {
7529
7848
  */
7530
7849
  insertForEachFrom<T extends CreateSelf>(this: T, query: IsQuery): InsertManyFromResult<T>;
7531
7850
  }
7532
- interface CreateSelf extends PickQueryHasSelect, PickQueryDefaults, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryUniqueProperties, PickQueryInputType, Query.Pick.IsNotReadOnly {}
7851
+ interface CreateSelf extends PickQueryHasSelect, PickQueryDefaults, PickQueryResult, PickQueryRelations, PickQueryRelationsDataForCreate, PickQueryRelationsDataForCreateOptional, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryUniqueProperties, PickQueryInputType, Query.Pick.IsNotReadOnly {}
7533
7852
  type CreateData<T extends CreateSelf> = EmptyObject extends T['relations'] ? CreateDataWithDefaults<T, keyof T['__defaults']> : CreateRelationsData<T>;
7534
- type CreateDataWithDefaults<T extends CreateSelf, Defaults extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T, K> } & { [K in Defaults]?: K extends keyof T['inputType'] ? CreateColumn<T, K> : never };
7535
- type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends keyof T['inputType'], OmitFKeys extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T, K> } & { [K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T, K> };
7536
- type CreateColumn<T extends CreateSelf, K extends keyof T['inputType']> = T['inputType'][K] | ((q: T) => QueryOrExpression<T['inputType'][K]>);
7537
- type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsForRelations<T, keyof T['__defaults'], T['relations'][keyof T['relations']]['omitForeignKeyInCreate']> & CreateRelationsDataOmittingFKeys<T, T['relations'][keyof T['relations']]['dataForCreate']>;
7538
- type CreateRelationsDataOmittingFKeys<T extends CreateSelf, Union> = (Union extends RelationConfigDataForCreate ? (u: Union['columns'] extends keyof T['__defaults'] ? Pick<CreateDataWithDefaults<T, keyof T['__defaults']>, Union['columns']> & Partial<Union['nested']> : (Pick<{ [P in keyof T['inputType']]: CreateColumn<T, P> }, Union['columns'] & keyof T['inputType']> & { [K in keyof Union['nested']]?: never }) | Union['nested']) => void : (u: Union) => void) extends ((u: infer Obj) => void) ? Obj : never;
7853
+ type CreateDataWithDefaults<T extends CreateSelf, Defaults extends PropertyKey> = { [K in keyof T['__inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T, K> } & { [K in Defaults]?: K extends keyof T['__inputType'] ? CreateColumn<T, K> : never };
7854
+ type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends keyof T['__inputType'], OmitFKeys extends PropertyKey> = { [K in keyof T['__inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T, K> } & { [K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T, K> };
7855
+ type CreateColumn<T extends CreateSelf, K extends keyof T['__inputType']> = T['__inputType'][K] | ((q: T) => QueryOrExpression<T['__inputType'][K]>);
7856
+ type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsForRelations<T, keyof T['__defaults'], T['relations'][keyof T['relations']]['omitForeignKeyInCreate']> & CreateRelationsDataOmittingFKeys<T, T['relationsDataForCreate']> & T['relationsDataForCreateOptional'];
7857
+ type CreateRelationsDataOmittingFKeys<T extends CreateSelf, Data> = EmptyObject extends Data ? EmptyObject : { [K in keyof Data]: CreateRelationDataOmittingFKeys<T, Data[K]> }[keyof Data] extends ((u: infer Obj) => void) ? Obj : never;
7858
+ type CreateRelationDataOmittingFKeys<T extends CreateSelf, Union> = (u: Union extends RelationConfigDataForCreate ? Union['columns'] extends keyof T['__defaults'] ? Pick<CreateDataWithDefaults<T, keyof T['__defaults']>, Union['columns']> & Partial<Union['nested']> : (Pick<{ [P in keyof T['__inputType']]: CreateColumn<T, P> }, Union['columns'] & keyof T['__inputType']> & { [K in keyof Union['nested']]?: never }) | Union['nested'] : Union) => void;
7539
7859
  type CreateResult<T extends CreateSelf, Data> = T extends {
7540
7860
  isCount: true;
7541
7861
  } ? T : T['returnType'] extends undefined | 'all' ? SetQueryReturnsOneResult<T, NarrowCreateResult<T, Data>> : T['returnType'] extends 'pluck' ? SetQueryReturnsColumnResult<T, NarrowCreateResult<T, Data>> : SetQueryResult<T, NarrowCreateResult<T, Data>>;
@@ -7550,7 +7870,7 @@ type InsertManyResult<T extends CreateSelf> = T['__hasSelect'] extends true ? T[
7550
7870
  *
7551
7871
  * The same should work as well with any non-null columns passed to `create`, but it's to be implemented later.
7552
7872
  */
7553
- type NarrowCreateResult<T extends CreateSelf, Data> = EmptyObject extends T['relations'] ? T['result'] : { [K in keyof T['result']]: true extends { [R in keyof T['relations']]: K extends T['relations'][R]['omitForeignKeyInCreate'] ? R extends keyof Data ? true : T['relations'][R]['omitForeignKeyInCreate'] extends keyof Data ? null | undefined extends Data[T['relations'][R]['omitForeignKeyInCreate']] ? never : true : never : never }[keyof T['relations']] ? Column.Pick.QueryColumnOfTypeAndOps<string, Exclude<T['result'][K]['outputType'], null>, T['result'][K]['operators']> : T['result'][K] };
7873
+ type NarrowCreateResult<T extends CreateSelf, Data> = EmptyObject extends T['relations'] ? T['result'] : { [K in keyof T['result']]: true extends { [R in keyof T['relations']]: K extends T['relations'][R]['omitForeignKeyInCreate'] ? R extends keyof Data ? true : T['relations'][R]['omitForeignKeyInCreate'] extends keyof Data ? null | undefined extends Data[T['relations'][R]['omitForeignKeyInCreate']] ? never : true : never : never }[keyof T['relations']] ? Column.Pick.QueryColumnOfTypeAndOps<string, Exclude<T['result'][K]['__outputType'], null>, T['result'][K]['operators']> : T['result'][K] };
7554
7874
  type IgnoreResult<T extends CreateSelf> = T['returnType'] extends 'oneOrThrow' ? QueryTakeOptional<T> : T['returnType'] extends 'valueOrThrow' ? SetQueryReturnsColumnOptional<T, T['result']['value']> : T;
7555
7875
  type OnConflictArg<T extends PickQueryUniqueProperties> = T['internal']['uniqueColumnNames'] | T['internal']['uniqueColumnTuples'] | Expression | {
7556
7876
  constraint: T['internal']['uniqueConstraints'];
@@ -7577,7 +7897,7 @@ declare const _queryDefaults: <T extends CreateSelf, Data extends Partial<Create
7577
7897
  */
7578
7898
  type CreateMethodsNames = 'create' | 'insert' | 'createMany' | 'insertMany' | CreateFromMethodNames;
7579
7899
  type CreateManyMethodsNames = 'createMany' | 'insertMany' | CreateManyFromMethodNames;
7580
- type ExtraPropertiesAreNotAllowed<T extends CreateSelf, Data> = keyof Data extends keyof T['inputType'] | keyof T['relations'] ? Data : `Extra properties are not allowed: ${Exclude<keyof Data, keyof T['inputType'] | keyof T['relations']> & string}`;
7900
+ type ExtraPropertiesAreNotAllowed<T extends CreateSelf, Data> = keyof Data extends keyof T['__inputType'] | keyof T['relations'] ? Data : `Extra properties are not allowed: ${Exclude<keyof Data, keyof T['__inputType'] | keyof T['relations']> & string}`;
7581
7901
  declare class QueryCreate {
7582
7902
  /**
7583
7903
  * `create` and `insert` create a single record.
@@ -7851,7 +8171,7 @@ declare class QueryCreate {
7851
8171
  */
7852
8172
  onConflictDoNothing<T extends CreateSelf, Arg extends OnConflictArg<T>>(this: T, arg?: Arg): IgnoreResult<T>;
7853
8173
  }
7854
- type OnConflictSet$1<T extends CreateSelf> = { [K in keyof T['inputType']]?: T['inputType'][K] | (() => QueryOrExpression<T['inputType'][K]>) };
8174
+ type OnConflictSet$1<T extends CreateSelf> = { [K in keyof T['__inputType']]?: T['__inputType'][K] | (() => QueryOrExpression<T['__inputType'][K]>) };
7855
8175
  declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflictArg<T> | undefined> {
7856
8176
  private query;
7857
8177
  private onConflict;
@@ -7920,11 +8240,11 @@ declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflic
7920
8240
  }): T;
7921
8241
  }
7922
8242
  interface UpdateSelf extends PickQuerySelectable, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryInputType, PickQueryAs, PickQueryHasSelect, PickQueryHasWhere, Query.Pick.IsNotReadOnly {}
7923
- type UpdateData<T extends UpdateSelf> = { [K in keyof T['inputType'] | keyof T['relations']]?: K extends keyof T['inputType'] ? T['inputType'][K] | ((q: { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['query'] : K extends keyof T ? T[K] : never }) => QueryOrExpression<T['inputType'][K]>) : T['returnType'] extends undefined | 'all' ? T['relations'][K]['dataForUpdate'] : T['relations'][K]['dataForUpdateOne'] };
8243
+ type UpdateData<T extends UpdateSelf> = { [K in keyof T['__inputType'] | keyof T['relations']]?: K extends keyof T['__inputType'] ? T['__inputType'][K] | ((q: { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['query'] : K extends keyof T ? T[K] : never }) => QueryOrExpression<T['__inputType'][K]>) : T['returnType'] extends undefined | 'all' ? T['relations'][K]['dataForUpdate'] : T['relations'][K]['dataForUpdateOne'] };
7924
8244
  type UpdateArg<T extends UpdateSelf> = T['__hasWhere'] extends true ? UpdateData<T> : 'Update statement must have where conditions. To update all prefix `update` with `all()`';
7925
8245
  type UpdateResult<T extends UpdateSelf> = T['__hasSelect'] extends true ? T : T['returnType'] extends undefined | 'all' ? SetQueryReturnsRowCountMany<T> : SetQueryReturnsRowCount<T>;
7926
- type NumericColumns<T extends UpdateSelf> = { [K in keyof T['inputType']]: Exclude<T['shape'][K]['queryType'], string> extends number | bigint | null ? K : never }[keyof T['inputType']];
7927
- type ChangeCountArg<T extends UpdateSelf> = NumericColumns<T> | { [K in NumericColumns<T>]?: T['shape'][K]['type'] extends number | null ? number : number | string | bigint };
8246
+ type NumericColumns<T extends UpdateSelf> = { [K in keyof T['__inputType']]: Exclude<T['shape'][K]['__queryType'], string> extends number | bigint | null ? K : never }[keyof T['__inputType']];
8247
+ type ChangeCountArg<T extends UpdateSelf> = NumericColumns<T> | { [K in NumericColumns<T>]?: T['shape'][K]['__type'] extends number | null ? number : number | string | bigint };
7928
8248
  interface UpdateManyBySelf extends UpdateSelf {
7929
8249
  internal: {
7930
8250
  uniqueColumns: unknown;
@@ -7933,10 +8253,10 @@ interface UpdateManyBySelf extends UpdateSelf {
7933
8253
  uniqueConstraints: unknown;
7934
8254
  };
7935
8255
  }
7936
- type UpdateManyData<T extends UpdateSelf> = ({ [K in keyof T['shape'] as T['shape'][K] extends Column.Modifiers.IsPrimaryKey<string> ? K : never]: T['shape'][K]['queryType'] | Expression } & { [P in keyof T['inputType']]?: T['inputType'][P] | Expression })[];
8256
+ type UpdateManyData<T extends UpdateSelf> = ({ [K in keyof T['shape'] as T['shape'][K] extends Column.Modifiers.IsPrimaryKey<string> ? K : never]: T['shape'][K]['__queryType'] | Expression } & { [P in keyof T['__inputType']]?: T['__inputType'][P] | Expression })[];
7937
8257
  type UpdateManyByKeys<T extends UpdateManyBySelf> = T['internal']['uniqueColumnNames'] | T['internal']['uniqueColumnTuples'];
7938
8258
  type UpdateManyByKeyColumns<K> = K extends string[] ? K[number] : K;
7939
- type UpdateManyByData<T extends UpdateSelf, K> = ({ [P in K & keyof T['inputType']]: T['inputType'][P] } & { [P in keyof T['inputType']]?: P extends K ? T['inputType'][P] : T['inputType'][P] | Expression })[];
8259
+ type UpdateManyByData<T extends UpdateSelf, K> = ({ [P in K & keyof T['__inputType']]: T['__inputType'][P] } & { [P in keyof T['__inputType']]?: P extends K ? T['__inputType'][P] : T['__inputType'][P] | Expression })[];
7940
8260
  type UpdateManyResult<T extends UpdateSelf> = T['__hasSelect'] extends true ? T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAllResult<T, T['result']> : T['returnType'] extends 'value' | 'valueOrThrow' ? SetQueryReturnsPluckColumnResult<T, T['result']> : SetQueryResult<T, T['result']> : SetQueryReturnsRowCountMany<T>;
7941
8261
  declare const _queryUpdate: <T extends UpdateSelf>(updateSelf: T, arg: UpdateArg<T>) => UpdateResult<T>;
7942
8262
  declare const _queryUpdateOrThrow: <T extends UpdateSelf>(q: T, arg: UpdateArg<T>) => UpdateResult<T>;
@@ -8383,8 +8703,16 @@ declare class QueryUpdate {
8383
8703
  */
8384
8704
  updateManyByOptional<T extends UpdateManyBySelf, Keys extends UpdateManyByKeys<T>, K = UpdateManyByKeyColumns<Keys>>(this: T, keys: Keys, data: UpdateManyByData<T, K>): UpdateManyResult<T> & QueryHasWhere;
8385
8705
  }
8386
- declare abstract class VirtualColumn<Schema extends ColumnSchemaConfig, InputSchema extends Schema['type'] = ReturnType<Schema['never']>> extends Column<Schema, unknown, InputSchema, OperatorsAny> {
8706
+ declare abstract class VirtualColumn<Schema extends ColumnSchemaConfig, InputSchema extends Schema['__schemaType'] = ReturnType<Schema['never']>> extends Column {
8707
+ __schema: Schema;
8387
8708
  dataType: string;
8709
+ __type: unknown;
8710
+ __inputType: unknown;
8711
+ inputSchema: InputSchema;
8712
+ __outputType: unknown;
8713
+ outputSchema: InputSchema;
8714
+ __queryType: unknown;
8715
+ querySchema: ReturnType<Schema['never']>;
8388
8716
  operators: OperatorsAny;
8389
8717
  constructor(schema: Schema, inputSchema?: InputSchema);
8390
8718
  toCode(): never;
@@ -8421,20 +8749,20 @@ interface ComputedOptionsConfig {
8421
8749
  type ComputedOptionsFactory<ColumnTypes, Shape extends Column.QueryColumns> = (t: ComputedMethods<ColumnTypes, Shape>) => ComputedOptionsConfig;
8422
8750
  interface RuntimeComputedQueryColumn<OutputType> extends Column.Pick.QueryColumn {
8423
8751
  dataType: 'runtimeComputed';
8424
- type: never;
8425
- outputType: OutputType;
8426
- queryType: undefined;
8752
+ __type: never;
8753
+ __outputType: OutputType;
8754
+ __queryType: undefined;
8427
8755
  operators: {
8428
8756
  cannotQueryRuntimeComputed: never;
8429
8757
  };
8430
8758
  }
8431
8759
  interface ComputedMethods<ColumnTypes, Shape extends Column.QueryColumns> extends QueryComputedArg<ColumnTypes, Shape> {
8432
- computeAtRuntime<Deps extends keyof Shape, OutputType>(dependsOn: Deps[], fn: (record: { [K in keyof Shape & Deps]: Shape[K]['outputType'] }) => OutputType): {
8760
+ computeAtRuntime<Deps extends keyof Shape, OutputType>(dependsOn: Deps[], fn: (record: { [K in keyof Shape & Deps]: Shape[K]['__outputType'] }) => OutputType): {
8433
8761
  result: {
8434
8762
  value: RuntimeComputedQueryColumn<OutputType>;
8435
8763
  };
8436
8764
  };
8437
- computeBatchAtRuntime<Deps extends keyof Shape, OutputType>(dependsOn: Deps[], fn: (record: { [K in keyof Shape & Deps]: Shape[K]['outputType'] }[]) => MaybePromise<OutputType[]>): {
8765
+ computeBatchAtRuntime<Deps extends keyof Shape, OutputType>(dependsOn: Deps[], fn: (record: { [K in keyof Shape & Deps]: Shape[K]['__outputType'] }[]) => MaybePromise<OutputType[]>): {
8438
8766
  result: {
8439
8767
  value: RuntimeComputedQueryColumn<OutputType>;
8440
8768
  };
@@ -8840,7 +9168,7 @@ interface ToSQLQuery extends IsQuery {
8840
9168
  }
8841
9169
  interface FromQuerySelf extends PickQuerySelectable, PickQueryShape, PickQueryReturnType, PickQueryWithData, PickQueryAs, PickQueryHasSelect {}
8842
9170
  type FromArg<T extends FromQuerySelf> = IsQuery | Exclude<keyof T['withData'], symbol | number>;
8843
- type FromResult<T extends FromQuerySelf, Arg extends MaybeArray<FromArg<T>>> = Arg extends string ? T['withData'] extends WithDataItems ? { [K in keyof T]: K extends '__selectable' ? SelectableFromShape<T['withData'][Arg]['shape'], Arg> : K extends 'result' ? T['withData'][Arg]['shape'] : K extends 'then' ? QueryThenByQuery<T, T['withData'][Arg]['shape']> : T[K] } : SetQueryTableAlias<T, Arg> : Arg extends PickQuerySelectableResultInputTypeAs ? { [K in keyof T]: K extends '__defaultSelect' ? keyof Arg['result'] : K extends '__selectable' ? SelectableFromShape<Arg['result'], Arg['__as']> : K extends '__as' ? Arg['__as'] : K extends 'result' ? Arg['result'] : K extends 'shape' ? Arg['result'] : K extends 'inputType' ? Arg['inputType'] : K extends 'then' ? QueryThenByQuery<T, Arg['result']> : T[K] } : Arg extends (infer A)[] ? { [K in keyof T]: K extends '__selectable' ? UnionToIntersection<A extends string ? T['withData'] extends WithDataItems ? { [K in keyof T['withData'][A]['shape'] & string as `${A}.${K}`]: {
9171
+ type FromResult<T extends FromQuerySelf, Arg extends MaybeArray<FromArg<T>>> = Arg extends string ? T['withData'] extends WithDataItems ? { [K in keyof T]: K extends '__selectable' ? SelectableFromShape<T['withData'][Arg]['shape'], Arg> : K extends 'result' ? T['withData'][Arg]['shape'] : K extends 'then' ? QueryThenByQuery<T, T['withData'][Arg]['shape']> : T[K] } : SetQueryTableAlias<T, Arg> : Arg extends PickQuerySelectableResultInputTypeAs ? { [K in keyof T]: K extends '__defaultSelect' ? keyof Arg['result'] : K extends '__selectable' ? SelectableFromShape<Arg['result'], Arg['__as']> : K extends '__as' ? Arg['__as'] : K extends 'result' ? Arg['result'] : K extends 'shape' ? Arg['result'] : K extends '__inputType' ? Arg['__inputType'] : K extends 'then' ? QueryThenByQuery<T, Arg['result']> : T[K] } : Arg extends (infer A)[] ? { [K in keyof T]: K extends '__selectable' ? UnionToIntersection<A extends string ? T['withData'] extends WithDataItems ? { [K in keyof T['withData'][A]['shape'] & string as `${A}.${K}`]: {
8844
9172
  as: K;
8845
9173
  column: T['withData'][A]['shape'][K];
8846
9174
  } } : never : A extends PickQueryResultAs ? { [K in keyof A['result'] & string as `${A['__as']}.${K}`]: K extends string ? {
@@ -9181,7 +9509,7 @@ declare class CteQuery {
9181
9509
  }
9182
9510
  type UnionArgs<T extends PickQueryResult> = ({
9183
9511
  result: { [K in keyof T['result']]: {
9184
- queryType: T['result'][K]['queryType'];
9512
+ __queryType: T['result'][K]['__queryType'];
9185
9513
  } };
9186
9514
  } | ((q: T) => Expression))[];
9187
9515
  declare class Union {
@@ -9305,7 +9633,7 @@ declare class Clear {
9305
9633
  type HavingArgFn<T> = (q: T) => {
9306
9634
  result: {
9307
9635
  value: {
9308
- outputType: boolean;
9636
+ __outputType: boolean;
9309
9637
  };
9310
9638
  };
9311
9639
  };
@@ -9535,7 +9863,7 @@ interface QueryPluckSelf extends PickQuerySelectable, PickQueryRelationsWithData
9535
9863
  type PluckArg<T extends QueryPluckSelf> = SelectableOrExpression<T> | ((q: SelectAsFnArg<T>) => Expression | Query.Pick.SingleValueResult);
9536
9864
  type PluckResult<T extends QueryPluckSelf, S extends PluckArg<T>> = S extends ((q: never) => infer R) ? R extends Expression ? SetQueryReturnsPluck<T, R> : R extends Query.Pick.SingleValueResult ? { [K in keyof T]: K extends '__hasSelect' ? true : K extends 'result' ? {
9537
9865
  pluck: R['result']['value'];
9538
- } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<R['result']['value']['outputType'][]> : T[K] } : never : S extends SelectableOrExpression<T> ? SetQueryReturnsPluck<T, S> : never;
9866
+ } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<R['result']['value']['__outputType'][]> : T[K] } : never : S extends SelectableOrExpression<T> ? SetQueryReturnsPluck<T, S> : never;
9539
9867
  declare class QueryPluck {
9540
9868
  /**
9541
9869
  * `.pluck` returns a single array of a single selected column values:
@@ -9808,15 +10136,15 @@ type QueryHelperResult<T extends IsQueryHelper> = T['__result'];
9808
10136
  interface NarrowTypeSelf extends PickQueryResultReturnType {
9809
10137
  returnType: undefined | 'all' | 'one' | 'oneOrThrow' | 'value' | 'valueOrThrow' | 'pluck';
9810
10138
  }
9811
- type NarrowInvalidKeys<T extends PickQueryResult, Narrow> = { [K in keyof Narrow]: K extends keyof T['result'] ? Narrow[K] extends T['result'][K]['outputType'] ? never : K : K }[keyof Narrow];
10139
+ type NarrowInvalidKeys<T extends PickQueryResult, Narrow> = { [K in keyof Narrow]: K extends keyof T['result'] ? Narrow[K] extends T['result'][K]['__outputType'] ? never : K : K }[keyof Narrow];
9812
10140
  interface NarrowValueTypeResult<T extends PickQueryResultReturnType, Narrow> extends Column.QueryColumns {
9813
- value: { [K in keyof T['result']['value']]: K extends 'outputType' ? Narrow : T['result']['value'][K] };
10141
+ value: { [K in keyof T['result']['value']]: K extends '__outputType' ? Narrow : T['result']['value'][K] };
9814
10142
  }
9815
10143
  interface NarrowPluckTypeResult<T extends PickQueryResultReturnType, Narrow> extends Column.QueryColumns {
9816
- pluck: { [K in keyof T['result']['pluck']]: K extends 'outputType' ? Narrow extends unknown[] ? Narrow[number] : Narrow : T['result']['pluck'][K] };
10144
+ pluck: { [K in keyof T['result']['pluck']]: K extends '__outputType' ? Narrow extends unknown[] ? Narrow[number] : Narrow : T['result']['pluck'][K] };
9817
10145
  }
9818
10146
  type QueryIfResult<T extends PickQueryResultReturnType, R extends PickQueryResult> = { [K in keyof T]: K extends 'result' ? { [K in keyof T['result'] | keyof R['result']]: K extends keyof T['result'] ? K extends keyof R['result'] ? R['result'][K] | T['result'][K] : T['result'][K] : Column.Modifiers.QueryColumnToOptional<R['result'][K]> } : K extends 'then' ? QueryIfResultThen<T, R> : T[K] };
9819
- type QueryIfResultThen<T extends PickQueryResultReturnType, R extends PickQueryResult> = T['returnType'] extends undefined | 'all' ? QueryThenShallowSimplifyArr<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['outputType'] | R['result'][K]['outputType'] : T['result'][K]['outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['outputType'] }> : T['returnType'] extends 'one' ? QueryThenShallowSimplifyOptional<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['outputType'] | R['result'][K]['outputType'] : T['result'][K]['outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['outputType'] }> : T['returnType'] extends 'oneOrThrow' ? QueryThenShallowSimplify<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['outputType'] | R['result'][K]['outputType'] : T['result'][K]['outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['outputType'] }> : T['returnType'] extends 'value' ? QueryThen<T['result']['value']['outputType'] | R['result']['value']['outputType'] | undefined> : T['returnType'] extends 'valueOrThrow' ? QueryThen<T['result']['value']['outputType'] | R['result']['value']['outputType']> : T['returnType'] extends 'rows' ? QueryThen<(T['result'][keyof T['result']]['outputType'] | R['result'][keyof R['result']]['outputType'])[][]> : T['returnType'] extends 'pluck' ? QueryThen<(T['result']['pluck']['outputType'] | R['result']['pluck']['outputType'])[]> : QueryThen<void>;
10147
+ type QueryIfResultThen<T extends PickQueryResultReturnType, R extends PickQueryResult> = T['returnType'] extends undefined | 'all' ? QueryThenShallowSimplifyArr<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'one' ? QueryThenShallowSimplifyOptional<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'oneOrThrow' ? QueryThenShallowSimplify<{ [K in keyof T['result']]: K extends keyof R['result'] ? T['result'][K]['__outputType'] | R['result'][K]['__outputType'] : T['result'][K]['__outputType'] } & { [K in keyof R['result'] as K extends keyof T['result'] ? never : K]?: R['result'][K]['__outputType'] }> : T['returnType'] extends 'value' ? QueryThen<T['result']['value']['__outputType'] | R['result']['value']['__outputType'] | undefined> : T['returnType'] extends 'valueOrThrow' ? QueryThen<T['result']['value']['__outputType'] | R['result']['value']['__outputType']> : T['returnType'] extends 'rows' ? QueryThen<(T['result'][keyof T['result']]['__outputType'] | R['result'][keyof R['result']]['__outputType'])[][]> : T['returnType'] extends 'pluck' ? QueryThen<(T['result']['pluck']['__outputType'] | R['result']['pluck']['__outputType'])[]> : QueryThen<void>;
9820
10148
  interface QueryMethods<ColumnTypes> extends QueryClone, QueryAsMethods, AggregateMethods, QueryDistinct, Select, FromMethods, QueryJoin, QueryLimitOffset, CteQuery, Union, QueryJsonMethods, QueryCreate, QueryCreateFrom, QueryUpdate, QueryDelete, QueryStorage, QueryTransaction, QueryTruncate, For, Where, SearchMethods, Clear, Having, QueryCatchers, QueryLog, QueryOrder, QueryWithSchema, QueryHooks, QueryUpsert, QueryOrCreate, QueryGet, QueryPluck, MergeQueryMethods, QuerySql<ColumnTypes>, QueryTransform, QueryMap, QueryScope, SoftDeleteMethods, QueryExpressions, QueryWrap, QueryWindow {}
9821
10149
  declare class QueryMethods<ColumnTypes> {
9822
10150
  /**
@@ -10247,10 +10575,10 @@ declare class QueryMethods<ColumnTypes> {
10247
10575
  * ```
10248
10576
  */
10249
10577
  narrowType<T extends NarrowTypeSelf>(this: T): <Narrow>() => T['returnType'] extends undefined | 'all' | 'one' | 'oneOrThrow' ? [NarrowInvalidKeys<T, Narrow>] extends [never] ? { [K in keyof T]: K extends 'result' ? T['result'] & { [K in keyof Narrow]: {
10250
- outputType: Narrow[K];
10578
+ __outputType: Narrow[K];
10251
10579
  } } : K extends 'then' ? QueryThenByQuery<T, T['result'] & { [K in keyof Narrow]: {
10252
- outputType: Narrow[K];
10253
- } }> : T[K] } : `narrowType() error: provided type does not extend the '${NarrowInvalidKeys<T, Narrow> & string}' column type` : (T['returnType'] extends 'pluck' ? Narrow extends unknown[] ? Narrow[number] : Narrow : Narrow) extends (T['returnType'] extends 'pluck' ? T['result']['pluck']['outputType'] : T['result']['value']['outputType']) ? { [K in keyof T]: K extends 'result' ? T['returnType'] extends 'value' | 'valueOrThrow' ? NarrowValueTypeResult<T, Narrow> : NarrowPluckTypeResult<T, Narrow> : K extends 'then' ? QueryThenByQuery<T, T['returnType'] extends 'value' | 'valueOrThrow' ? NarrowValueTypeResult<T, Narrow> : NarrowPluckTypeResult<T, Narrow>> : T[K] } : 'narrowType() error: provided type does not extend the returning column column type';
10580
+ __outputType: Narrow[K];
10581
+ } }> : T[K] } : `narrowType() error: provided type does not extend the '${NarrowInvalidKeys<T, Narrow> & string}' column type` : (T['returnType'] extends 'pluck' ? Narrow extends unknown[] ? Narrow[number] : Narrow : Narrow) extends (T['returnType'] extends 'pluck' ? T['result']['pluck']['__outputType'] : T['result']['value']['__outputType']) ? { [K in keyof T]: K extends 'result' ? T['returnType'] extends 'value' | 'valueOrThrow' ? NarrowValueTypeResult<T, Narrow> : NarrowPluckTypeResult<T, Narrow> : K extends 'then' ? QueryThenByQuery<T, T['returnType'] extends 'value' | 'valueOrThrow' ? NarrowValueTypeResult<T, Narrow> : NarrowPluckTypeResult<T, Narrow>> : T[K] } : 'narrowType() error: provided type does not extend the returning column column type';
10254
10582
  if<T extends PickQueryResultReturnType, R extends PickQueryResult>(this: T, condition: boolean | null | undefined, fn: (q: T) => R & {
10255
10583
  returnType: T['returnType'];
10256
10584
  }): QueryIfResult<T, R>;
@@ -10324,12 +10652,14 @@ interface Query extends IsQuery, PickQueryTable, PickQueryShape, PickQuerySelect
10324
10652
  returnType: QueryReturnType;
10325
10653
  qb: QueryBuilder;
10326
10654
  columnTypes: unknown;
10327
- inputType: RecordUnknown;
10655
+ __inputType: RecordUnknown;
10328
10656
  q: QueryData;
10329
10657
  then: QueryThen<unknown>;
10330
10658
  catch: QueryCatch;
10331
10659
  windows: EmptyObject;
10332
10660
  relations: RelationsBase;
10661
+ relationsDataForCreate: RelationsDataForCreateBase;
10662
+ relationsDataForCreateOptional: RelationsDataForCreateOptionalBase;
10333
10663
  relationQueries: IsQueries;
10334
10664
  error: new (message: string, length: number, name: QueryErrorName) => QueryError;
10335
10665
  __readOnly: true | undefined;
@@ -10361,43 +10691,43 @@ declare namespace Query {
10361
10691
  }
10362
10692
  }
10363
10693
  }
10364
- type SelectableOfType<T extends PickQuerySelectable, Type> = { [K in keyof T['__selectable']]: T['__selectable'][K]['column']['type'] extends Type | null ? K : never }[keyof T['__selectable']];
10365
- type SelectableOrExpressionOfType<T extends PickQuerySelectable, C extends Column.Pick.Type> = SelectableOfType<T, C['type']> | Expression<Column.Pick.QueryColumnOfType<C['type'] | null>>;
10694
+ type SelectableOfType<T extends PickQuerySelectable, Type> = { [K in keyof T['__selectable']]: T['__selectable'][K]['column']['__type'] extends Type | null ? K : never }[keyof T['__selectable']];
10695
+ type SelectableOrExpressionOfType<T extends PickQuerySelectable, C extends Column.Pick.Type> = SelectableOfType<T, C['__type']> | Expression<Column.Pick.QueryColumnOfType<C['__type'] | null>>;
10366
10696
  type SetQueryReturnsAll<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'all' : K extends 'then' ? QueryThenShallowSimplifyArr<ColumnsShape.Output<T['result']>> : T[K] } & QueryHasWhere;
10367
10697
  type SetQueryReturnsAllResult<T extends PickQueryResult, Result extends Column.QueryColumns> = { [K in keyof T]: K extends 'returnType' ? 'all' : K extends 'result' ? Result : K extends 'then' ? QueryThenShallowSimplifyArr<T['result']> : T[K] } & QueryHasWhere;
10368
- type QueryTakeOptional<T extends PickQueryResultReturnType> = T['returnType'] extends 'value' | 'pluck' | 'void' ? T : T['returnType'] extends 'valueOrThrow' ? { [K in keyof T]: K extends 'returnType' ? 'value' : K extends 'then' ? QueryThen<T['result']['value']['outputType'] | undefined> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'one' : K extends 'then' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<T['result']>> : T[K] };
10698
+ type QueryTakeOptional<T extends PickQueryResultReturnType> = T['returnType'] extends 'value' | 'pluck' | 'void' ? T : T['returnType'] extends 'valueOrThrow' ? { [K in keyof T]: K extends 'returnType' ? 'value' : K extends 'then' ? QueryThen<T['result']['value']['__outputType'] | undefined> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'one' : K extends 'then' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<T['result']>> : T[K] };
10369
10699
  type QueryManyTakeOptional<T extends PickQueryResultReturnType> = { [K in keyof T]: K extends 'returnType' ? 'one' : K extends 'then' ? QueryThenShallowSimplifyOptional<ColumnsShape.Output<T['result']>> : T[K] };
10370
- type QueryTake<T extends PickQueryResultReturnType> = T['returnType'] extends 'valueOrThrow' | 'pluck' | 'void' ? T : T['returnType'] extends 'value' ? { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Exclude<T['result']['value']['outputType'], undefined>> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
10700
+ type QueryTake<T extends PickQueryResultReturnType> = T['returnType'] extends 'valueOrThrow' | 'pluck' | 'void' ? T : T['returnType'] extends 'value' ? { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Exclude<T['result']['value']['__outputType'], undefined>> : T[K] } : { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
10371
10701
  type QueryManyTake<T extends PickQueryResultReturnType> = { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
10372
10702
  type SetQueryReturnsOne<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<T['result']>> : T[K] };
10373
10703
  type SetQueryReturnsOneResult<T extends PickQueryResult, Result extends Column.QueryColumns> = { [K in keyof T]: K extends 'returnType' ? 'oneOrThrow' : K extends 'result' ? Result : K extends 'then' ? QueryThenShallowSimplify<ColumnsShape.Output<Result>> : T[K] };
10374
10704
  type SetQueryReturnsRows<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'rows' : K extends 'then' ? QueryThen<ColumnsShape.Output<T['result']>[keyof T['result']][][]> : T[K] };
10375
10705
  type SetQueryReturnsPluck<T extends PickQuerySelectable, S extends keyof T['__selectable'] | Expression> = S extends keyof T['__selectable'] ? { [K in keyof T]: K extends '__hasSelect' ? true : K extends 'result' ? {
10376
10706
  pluck: T['__selectable'][S]['column'];
10377
- } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<T['__selectable'][S]['column']['outputType'][]> : T[K] } : { [K in keyof T]: K extends '__hasSelect' ? true : K extends 'result' ? {
10707
+ } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<T['__selectable'][S]['column']['__outputType'][]> : T[K] } : { [K in keyof T]: K extends '__hasSelect' ? true : K extends 'result' ? {
10378
10708
  pluck: S extends Expression ? S['result']['value'] : never;
10379
- } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<(S extends Expression ? S['result']['value']['outputType'] : never)[]> : T[K] };
10709
+ } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<(S extends Expression ? S['result']['value']['__outputType'] : never)[]> : T[K] };
10380
10710
  type SetValueQueryReturnsPluckColumn<T extends PickQueryResult> = { [K in keyof T]: K extends 'result' ? {
10381
10711
  pluck: T['result']['value'];
10382
- } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<T['result']['value']['outputType'][]> : T[K] } & QueryHasSelect;
10712
+ } : K extends 'returnType' ? 'pluck' : K extends 'then' ? QueryThen<T['result']['value']['__outputType'][]> : T[K] } & QueryHasSelect;
10383
10713
  type SetQueryReturnsPluckColumnResult<T extends PickQueryResult, Result extends Column.QueryColumns> = { [K in keyof T]: K extends 'result' ? {
10384
10714
  pluck: T['result']['value'];
10385
- } : K extends 'returnType' ? 'pluck' : K extends 'result' ? Result : K extends 'then' ? QueryThen<T['result']['value']['outputType'][]> : T[K] } & QueryHasSelect;
10715
+ } : K extends 'returnType' ? 'pluck' : K extends 'result' ? Result : K extends 'then' ? QueryThen<T['result']['value']['__outputType'][]> : T[K] } & QueryHasSelect;
10386
10716
  type SetQueryReturnsValueOrThrow<T extends PickQuerySelectable, Arg extends keyof T['__selectable']> = SetQueryReturnsColumnOrThrow<T, T['__selectable'][Arg]['column']> & T['__selectable'][Arg]['column']['operators'];
10387
- type SetValueQueryReturnsValueOrThrow<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<T['result']['value']['outputType']> : T[K] };
10388
- type SetQueryReturnsValueOptional<T extends PickQuerySelectable, Arg extends GetStringArg<T>> = SetQueryReturnsColumnOptional<T, { [K in keyof T['__selectable'][Arg]['column']]: K extends 'outputType' ? T['__selectable'][Arg]['column'][K] | undefined : T['__selectable'][Arg]['column'][K] }> & Omit<T['__selectable'][Arg]['column']['operators'], 'equals' | 'not'> & Column.Modifiers.OperatorsNullable<T['__selectable'][Arg]['column']>;
10717
+ type SetValueQueryReturnsValueOrThrow<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<T['result']['value']['__outputType']> : T[K] };
10718
+ type SetQueryReturnsValueOptional<T extends PickQuerySelectable, Arg extends GetStringArg<T>> = SetQueryReturnsColumnOptional<T, { [K in keyof T['__selectable'][Arg]['column']]: K extends '__outputType' ? T['__selectable'][Arg]['column'][K] | undefined : T['__selectable'][Arg]['column'][K] }> & Omit<T['__selectable'][Arg]['column']['operators'], 'equals' | 'not'> & Column.Modifiers.OperatorsNullable<T['__selectable'][Arg]['column']>;
10389
10719
  type SetQueryReturnsColumnOrThrow<T, Column extends Column.Pick.OutputType> = { [K in keyof T]: K extends 'result' ? {
10390
10720
  value: Column;
10391
- } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Column['outputType']> : T[K] } & QueryHasSelect;
10721
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<Column['__outputType']> : T[K] } & QueryHasSelect;
10392
10722
  type SetQueryReturnsColumnOptional<T, Column extends Column.Pick.OutputType> = { [K in keyof T]: K extends 'result' ? {
10393
10723
  value: Column;
10394
- } : K extends 'returnType' ? 'value' : K extends 'then' ? QueryThen<Column['outputType'] | undefined> : T[K] } & QueryHasSelect;
10724
+ } : K extends 'returnType' ? 'value' : K extends 'then' ? QueryThen<Column['__outputType'] | undefined> : T[K] } & QueryHasSelect;
10395
10725
  type SetQueryReturnsColumn<T extends PickQueryResult> = { [K in keyof T]: K extends 'result' ? {
10396
10726
  value: T['result']['pluck'];
10397
- } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<T['result']['pluck']['outputType']> : T[K] } & QueryHasSelect;
10727
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<T['result']['pluck']['__outputType']> : T[K] } & QueryHasSelect;
10398
10728
  type SetQueryReturnsColumnResult<T extends PickQueryResult, Result extends Column.QueryColumns> = { [K in keyof T]: K extends 'result' ? {
10399
10729
  value: T['result']['pluck'];
10400
- } : K extends 'returnType' ? 'valueOrThrow' : K extends 'result' ? Result : K extends 'then' ? QueryThen<Result['pluck']['outputType']> : T[K] } & QueryHasSelect;
10730
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'result' ? Result : K extends 'then' ? QueryThen<Result['pluck']['__outputType']> : T[K] } & QueryHasSelect;
10401
10731
  type SetQueryReturnsRowCount<T extends PickQueryResult> = { [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'result' ? {
10402
10732
  value: Column.Pick.QueryColumnOfType<number>;
10403
10733
  } : K extends 'then' ? QueryThen<number> : T[K] };
@@ -10429,7 +10759,6 @@ interface RelationConfigBase extends IsQuery {
10429
10759
  queryRelated(params: unknown): unknown;
10430
10760
  modifyRelatedQuery?(relatedQuery: IsQuery): (query: IsQuery) => void;
10431
10761
  omitForeignKeyInCreate: PropertyKey;
10432
- dataForCreate: unknown;
10433
10762
  dataForUpdate: unknown;
10434
10763
  dataForUpdateOne: unknown;
10435
10764
  primaryKeys: string[];
@@ -10439,7 +10768,13 @@ interface RelationConfigDataForCreate {
10439
10768
  nested: RecordUnknown;
10440
10769
  }
10441
10770
  interface RelationsBase {
10442
- [K: string]: RelationConfigBase;
10771
+ [relationName: string]: RelationConfigBase;
10772
+ }
10773
+ interface RelationsDataForCreateBase {
10774
+ [relationName: string]: unknown;
10775
+ }
10776
+ interface RelationsDataForCreateOptionalBase {
10777
+ [relationName: string]: unknown;
10443
10778
  }
10444
10779
  type RelationQueryMaybeSingle<T extends RelationConfigBase> = T['returnsOne'] extends true ? T['required'] extends true ? QueryManyTake<T['query']> : QueryManyTakeOptional<T['query']> : T['query'];
10445
10780
  interface PickQueryTable {
@@ -10518,7 +10853,7 @@ interface PickQueryUniqueProperties {
10518
10853
  };
10519
10854
  }
10520
10855
  interface PickQueryInputType {
10521
- inputType: RecordUnknown;
10856
+ __inputType: RecordUnknown;
10522
10857
  }
10523
10858
  interface PickQueryWithData {
10524
10859
  withData: WithDataItems;
@@ -10529,6 +10864,12 @@ interface PickQueryWindows {
10529
10864
  interface PickQueryRelations {
10530
10865
  relations: RelationsBase;
10531
10866
  }
10867
+ interface PickQueryRelationsDataForCreate {
10868
+ relationsDataForCreate: RelationsDataForCreateBase;
10869
+ }
10870
+ interface PickQueryRelationsDataForCreateOptional {
10871
+ relationsDataForCreateOptional: RelationsDataForCreateOptionalBase;
10872
+ }
10532
10873
  interface PickQueryColumTypes {
10533
10874
  columnTypes: unknown;
10534
10875
  }
@@ -10761,4 +11102,4 @@ declare const testTransaction: {
10761
11102
  */
10762
11103
  close(arg: Arg$1): Promise<void>;
10763
11104
  };
10764
- export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RefreshMaterializedViewOptions, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, refreshMaterializedView, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
11105
+ export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, type OperatorsText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RefreshMaterializedViewOptions, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, refreshMaterializedView, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };