pqb 0.30.6 → 0.31.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
@@ -106,11 +106,12 @@ interface QueryBaseThen<T> extends QueryBase {
106
106
  }
107
107
 
108
108
  declare const checkIfASimpleQuery: (q: Query) => boolean;
109
- type WithItem = [
110
- as: string,
111
- options: WithOptions,
112
- query: Query | Expression
113
- ];
109
+ type WithItem = {
110
+ n: string;
111
+ o?: WithOptions;
112
+ q?: Query;
113
+ s?: Expression;
114
+ };
114
115
  interface WithOptions {
115
116
  columns?: string[];
116
117
  recursive?: true;
@@ -288,7 +289,14 @@ interface WindowDeclaration {
288
289
  partitionBy?: SelectableOrExpression | SelectableOrExpression[];
289
290
  order?: OrderItem;
290
291
  }
291
- type UnionItem = Query | Expression;
292
+ interface UnionItem {
293
+ a: Query | Expression;
294
+ k: UnionKind;
295
+ }
296
+ interface UnionSet {
297
+ b: Query;
298
+ u: UnionItem[];
299
+ }
292
300
  type UnionKind = 'UNION' | 'UNION ALL' | 'INTERSECT' | 'INTERSECT ALL' | 'EXCEPT' | 'EXCEPT ALL';
293
301
  type OnConflictTarget = string | string[] | Expression | {
294
302
  constraint: string;
@@ -461,10 +469,9 @@ interface SelectQueryData extends CommonQueryData {
461
469
  having?: HavingItem[];
462
470
  window?: WindowItem[];
463
471
  union?: {
464
- arg: UnionItem;
465
- kind: UnionKind;
466
- wrap?: boolean;
467
- }[];
472
+ b: Query;
473
+ u: UnionItem[];
474
+ };
468
475
  order?: OrderItem[];
469
476
  returnsOne?: true;
470
477
  limit?: number;
@@ -615,7 +622,7 @@ type JoinFirstArg<T extends PickQueryRelationsWithData> = PickQueryTableMetaResu
615
622
  * Arguments of `join` methods (not `joinLateral`).
616
623
  * See {@link join}
617
624
  */
618
- type JoinArgs<T extends PickQueryMetaShapeRelationsWithData, Arg extends JoinFirstArg<T>> = [JoinCallback<T, Arg>] | (Arg extends PickQueryTableMetaResult ? JoinQueryArgs<T, Arg> : Arg extends keyof T['relations'] ? EmptyTuple : Arg extends keyof T['withData'] ? JoinWithArgs<T, Arg> : never);
625
+ type JoinArgs<T extends PickQueryMetaShapeRelationsWithData, Arg extends JoinFirstArg<T>> = [on?: JoinCallback<T, Arg>] | (Arg extends PickQueryTableMetaResult ? JoinQueryArgs<T, Arg> : Arg extends keyof T['relations'] ? EmptyTuple : Arg extends keyof T['withData'] ? JoinWithArgs<T, Arg> : never);
619
626
  /**
620
627
  * Column names of the joined table that can be used to join.
621
628
  * Derived from 'result', not from 'shape',
@@ -1382,7 +1389,7 @@ declare const _queryJoinOnJsonPathEquals: <T extends PickQueryMeta>(q: T, args:
1382
1389
  */
1383
1390
  type JoinQueryBuilder<T extends PickQueryMetaShape = PickQueryMetaShape, J extends PickQueryTableMetaResult = PickQueryTableMetaResult> = {
1384
1391
  [K in keyof J]: K extends 'meta' ? {
1385
- [K in keyof J['meta']]: K extends 'selectable' ? J['meta']['selectable'] & Omit<T['meta']['selectable'], keyof T['shape']> : J['meta'][K];
1392
+ [K in keyof J['meta']]: K extends 'selectable' ? SelectableFromShape<J['result'], AliasOrTable<J>> & Omit<T['meta']['selectable'], keyof T['shape']> : J['meta'][K];
1386
1393
  } : J[K];
1387
1394
  } & OnMethods;
1388
1395
  declare class OnMethods {
@@ -3798,19 +3805,16 @@ interface CreateSelf extends QueryBase {
3798
3805
  }
3799
3806
  type CreateData<T extends CreateSelf, BelongsToData = CreateBelongsToData<T>> = RelationsBase extends T['relations'] ? CreateDataWithDefaults<T, keyof T['meta']['defaults']> : CreateRelationsData<T, BelongsToData>;
3800
3807
  type CreateDataWithDefaults<T extends CreateSelf, Defaults extends PropertyKey> = {
3801
- [K in keyof T['inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T['inputType'], K>;
3808
+ [K in keyof T['inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T, K>;
3802
3809
  } & {
3803
- [K in Defaults]?: K extends keyof T['inputType'] ? CreateColumn<T['inputType'], K> : never;
3810
+ [K in Defaults]?: K extends keyof T['inputType'] ? CreateColumn<T, K> : never;
3804
3811
  };
3805
3812
  type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends keyof T['inputType'], OmitFKeys extends PropertyKey> = {
3806
- [K in keyof T['inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T['inputType'], K>;
3813
+ [K in keyof T['inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T, K>;
3807
3814
  } & {
3808
- [K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T['inputType'], K>;
3809
- };
3810
- type CreateColumn<InputType, Key extends keyof InputType> = Expression | InputType[Key] | {
3811
- __isQuery: true;
3812
- then: QueryThen<InputType[Key]>;
3815
+ [K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T, K>;
3813
3816
  };
3817
+ type CreateColumn<T extends CreateSelf, K extends keyof T['inputType']> = T['inputType'][K] | QueryOrExpression<T['inputType'][K]> | ((q: T) => QueryOrExpression<T['inputType'][K]>);
3814
3818
  type CreateRelationsData<T extends CreateSelf, BelongsToData> = CreateDataWithDefaultsForRelations<T, keyof T['meta']['defaults'], T['relations'][keyof T['relations']]['relationConfig']['omitForeignKeyInCreate']> & BelongsToData & T['relations'][keyof T['relations']]['relationConfig']['optionalDataForCreate'];
3815
3819
  type CreateBelongsToData<T extends CreateSelf> = CreateRelationsDataOmittingFKeys<T, T['relations'][keyof T['relations']]['relationConfig']['dataForCreate']>;
3816
3820
  type CreateRelationsDataOmittingFKeys<T extends CreateSelf, Union> = (Union extends RelationConfigDataForCreate ? (u: keyof Union['columns'] extends keyof T['meta']['defaults'] ? Omit<Union['columns'], keyof T['meta']['defaults']> & {
@@ -3918,7 +3922,7 @@ declare class Create {
3918
3922
  *
3919
3923
  * await db.table.create({
3920
3924
  * // raw SQL
3921
- * column1: sql`'John' || ' ' || 'Doe'`,
3925
+ * column1: (q) => q.sql`'John' || ' ' || 'Doe'`,
3922
3926
  *
3923
3927
  * // query that returns a single value
3924
3928
  * // returning multiple values will result in Postgres error
@@ -4403,15 +4407,10 @@ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
4403
4407
  type FromResult<T extends FromQuerySelf, Arg extends MaybeArray<FromArg<T>>> = Arg extends string ? T['withData'] extends WithDataItems ? {
4404
4408
  [K in keyof T]: K extends 'meta' ? {
4405
4409
  [K in keyof T['meta']]: K extends 'as' ? string | undefined : K extends 'selectable' ? SelectableFromShape<T['withData'][Arg]['shape'], Arg> : T['meta'][K];
4406
- } : T[K];
4410
+ } : K extends 'result' ? T['withData'][Arg]['shape'] : K extends 'then' ? QueryThen<GetQueryResult<T, T['withData'][Arg]['shape']>> : T[K];
4407
4411
  } : SetQueryTableAlias<T, Arg> : Arg extends PickQueryTableMetaResult ? {
4408
4412
  [K in keyof T]: K extends 'meta' ? {
4409
- [K in keyof T['meta']]: K extends 'as' ? AliasOrTable<Arg> : K extends 'selectable' ? {
4410
- [K in keyof Arg['result']]: K extends string ? {
4411
- as: K;
4412
- column: Arg['result'][K];
4413
- } : never;
4414
- } : T['meta'][K];
4413
+ [K in keyof T['meta']]: K extends 'as' ? AliasOrTable<Arg> : K extends 'selectable' ? SelectableFromShape<Arg['result'], AliasOrTable<Arg>> : T['meta'][K];
4415
4414
  } : K extends 'result' ? Arg['result'] : K extends 'shape' ? Arg['result'] : K extends 'then' ? QueryThen<GetQueryResult<T, Arg['result']>> : T[K];
4416
4415
  } : Arg extends (infer A)[] ? {
4417
4416
  [K in keyof T]: K extends 'meta' ? {
@@ -4430,7 +4429,7 @@ type FromResult<T extends FromQuerySelf, Arg extends MaybeArray<FromArg<T>>> = A
4430
4429
  } : T;
4431
4430
  declare function queryFrom<T extends FromQuerySelf, Arg extends MaybeArray<FromArg<T>>>(self: T, arg: Arg): FromResult<T, Arg>;
4432
4431
  declare function queryFromSql<T extends FromQuerySelf>(self: T, args: SQLQueryArgs): T;
4433
- declare class From {
4432
+ declare class FromMethods {
4434
4433
  /**
4435
4434
  * Set the `FROM` value, by default the table name is used.
4436
4435
  *
@@ -5094,16 +5093,178 @@ declare class Select {
5094
5093
  selectAll<T extends SelectSelf>(this: T): SelectResult<T, ['*']>;
5095
5094
  }
5096
5095
 
5097
- type WithArgsOptions = {
5098
- [K in keyof WithOptions]: K extends 'columns' ? boolean | string[] : WithOptions[K];
5096
+ declare class SqlMethod<ColumnTypes> {
5097
+ /**
5098
+ * When there is a need to use a piece of raw SQL, use the `sql` exported from the `BaseTable` file, it is also attached to query objects for convenience.
5099
+ *
5100
+ * When selecting a custom SQL, specify a resulting type with `<generic>` syntax:
5101
+ *
5102
+ * ```ts
5103
+ * import { sql } from './baseTable';
5104
+ *
5105
+ * const result: { num: number }[] = await db.table.select({
5106
+ * num: sql<number>`random() * 100`,
5107
+ * });
5108
+ * ```
5109
+ *
5110
+ * In a situation when you want the result to be parsed, such as when returning a timestamp that you want to be parsed into a `Date` object, provide a column type in such a way:
5111
+ *
5112
+ * This example assumes that the `timestamp` column was overridden with `asDate` as shown in [Override column types](/guide/columns-overview#override-column-types).
5113
+ *
5114
+ * ```ts
5115
+ * import { sql } from './baseTable';
5116
+ *
5117
+ * const result: { timestamp: Date }[] = await db.table.select({
5118
+ * timestamp: sql`now()`.type((t) => t.timestamp()),
5119
+ * });
5120
+ * ```
5121
+ *
5122
+ * In some cases such as when using [from](/guide/orm-and-query-builder.html#from), setting column type via callback allows for special `where` operations:
5123
+ *
5124
+ * ```ts
5125
+ * const subQuery = db.someTable.select({
5126
+ * sum: (q) => q.sql`$a + $b`.type((t) => t.decimal()).values({ a: 1, b: 2 }),
5127
+ * });
5128
+ *
5129
+ * // `gt`, `gte`, `min`, `lt`, `lte`, `max` in `where`
5130
+ * // are allowed only for numeric columns:
5131
+ * const result = await db.$from(subQuery).where({ sum: { gte: 5 } });
5132
+ * ```
5133
+ *
5134
+ * Many query methods have a version suffixed with `Sql`, you can pass an SQL template literal directly to these methods.
5135
+ * These methods are: `whereSql`, `whereNotSql`, `orderSql`, `havingSql`, `fromSql`, `findBySql`.
5136
+ *
5137
+ * ```ts
5138
+ * await db.table.whereSql`"someValue" = random() * 100`;
5139
+ * ```
5140
+ *
5141
+ * Interpolating values in template literals is completely safe:
5142
+ *
5143
+ * ```ts
5144
+ * // get value from user-provided params
5145
+ * const { value } = req.params;
5146
+ *
5147
+ * // SQL injection is prevented by a library, this is safe:
5148
+ * await db.table.whereSql`column = ${value}`;
5149
+ * ```
5150
+ *
5151
+ * In the example above, TS cannot check if the table has `column` column, or if there are joined tables that have such column which will lead to error.
5152
+ * Instead, use the [column](/guide/sql-expressions#column) or [ref](/guide/sql-expressions#ref) to reference a column:
5153
+ *
5154
+ * ```ts
5155
+ * // ids will be prefixed with proper table names, no ambiguity:
5156
+ * db.table.join(db.otherTable, 'id', 'otherId').where`
5157
+ * ${db.table.column('id')} = 1 AND
5158
+ * ${db.otherTable.ref('id')} = 2
5159
+ * `;
5160
+ * ```
5161
+ *
5162
+ * SQL can be passed with a simple string, it's important to note that this is not safe to interpolate values in it.
5163
+ *
5164
+ * ```ts
5165
+ * import { sql } from './baseTable';
5166
+ *
5167
+ * // no interpolation is okay
5168
+ * await db.table.where(sql({ raw: 'column = random() * 100' }));
5169
+ *
5170
+ * // get value from user-provided params
5171
+ * const { value } = req.params;
5172
+ *
5173
+ * // this is NOT safe, SQL injection is possible:
5174
+ * await db.table.where(sql({ raw: `column = random() * ${value}` }));
5175
+ * ```
5176
+ *
5177
+ * To inject values into `sql({ raw: '...' })` SQL strings, denote it with `$` in the string and provide `values` object.
5178
+ *
5179
+ * Use `$$` to provide column or/and table name (`column` or `ref` are preferable). Column names will be quoted so don't quote them manually.
5180
+ *
5181
+ * ```ts
5182
+ * import { sql } from './baseTable';
5183
+ *
5184
+ * // get value from user-provided params
5185
+ * const { value } = req.params;
5186
+ *
5187
+ * // this is SAFE, SQL injection are prevented:
5188
+ * await db.table.where(
5189
+ * sql<boolean>({
5190
+ * raw: '$$column = random() * $value',
5191
+ * values: {
5192
+ * column: 'someTable.someColumn', // or simply 'column'
5193
+ * one: value,
5194
+ * two: 123,
5195
+ * },
5196
+ * }),
5197
+ * );
5198
+ * ```
5199
+ *
5200
+ * Summarizing:
5201
+ *
5202
+ * ```ts
5203
+ * import { sql } from './baseTable';
5204
+ *
5205
+ * // simplest form:
5206
+ * sql`key = ${value}`;
5207
+ *
5208
+ * // with resulting type:
5209
+ * sql<boolean>`key = ${value}`;
5210
+ *
5211
+ * // with column type for select:
5212
+ * sql`key = ${value}`.type((t) => t.boolean());
5213
+ *
5214
+ * // with column name via `column` method:
5215
+ * sql`${db.table.column('column')} = ${value}`;
5216
+ *
5217
+ * // raw SQL string, not allowed to interpolate values:
5218
+ * sql({ raw: 'random()' });
5219
+ *
5220
+ * // with resulting type and `raw` string:
5221
+ * sql<number>({ raw: 'random()' });
5222
+ *
5223
+ * // with column name and a value in a `raw` string:
5224
+ * sql({
5225
+ * raw: `$$column = $value`,
5226
+ * values: { column: 'columnName', value: 123 },
5227
+ * });
5228
+ *
5229
+ * // combine template literal, column type, and values:
5230
+ * sql`($one + $two) / $one`.type((t) => t.numeric()).values({ one: 1, two: 2 });
5231
+ * ```
5232
+ *
5233
+ * @param args - template literal or an object { raw: string }
5234
+ * @return object that has `type` and `values` methods
5235
+ */
5236
+ sql<T = unknown>(this: PickQueryColumnTypes, ...args: StaticSQLArgs): RawSQL<QueryColumn<T>, ColumnTypes>;
5237
+ sql<T = unknown>(this: PickQueryColumnTypes, ...args: [DynamicSQLArg]): DynamicRawSQL<QueryColumn<T>, ColumnTypes>;
5238
+ }
5239
+
5240
+ interface WithArgsOptions {
5241
+ columns?: string[] | boolean;
5242
+ materialized?: true;
5243
+ notMaterialized?: true;
5244
+ }
5245
+ interface WithRecursiveOptions extends WithArgsOptions {
5246
+ union?: 'UNION' | 'UNION ALL' | 'INTERSECT' | 'INTERSECT ALL' | 'EXCEPT' | 'EXCEPT ALL';
5247
+ }
5248
+ type WithQueryBuilder<T extends PickQueryWithDataColumnTypes> = {
5249
+ [K in keyof Query]: K extends 'sql' ? SqlMethod<T['columnTypes']>['sql'] : K extends 'relations' ? EmptyObject : K extends 'withData' ? T['withData'] : Query[K];
5099
5250
  };
5100
- type WithArgs = [string, ColumnsShapeBase, Expression] | [string, WithArgsOptions, ColumnsShapeBase, Expression] | [string, Query | ((qb: Db) => Query)] | [string, WithArgsOptions, Query | ((qb: Db) => Query)];
5101
- type WithShape<Args extends WithArgs> = Args[1] extends Query ? Args[1]['result'] : Args[1] extends (qb: Db) => Query ? ReturnType<Args[1]>['result'] : Args[2] extends Query ? Args[2]['result'] : Args[2] extends (qb: Db) => Query ? ReturnType<Args[2]>['result'] : Args[1] extends ColumnsShapeBase ? Args[1] : Args[2] extends ColumnsShapeBase ? Args[2] : Args[2] extends (t: DefaultColumnTypes<ColumnSchemaConfig>) => ColumnsShapeBase ? ReturnType<Args[2]> extends ColumnsShapeBase ? ReturnType<Args[2]> : never : never;
5102
- type WithResult<T extends PickQueryWithData, Args extends WithArgs, Shape extends QueryColumns> = AddQueryWith<T, {
5103
- table: Args[0];
5104
- shape: Shape;
5105
- }>;
5106
- declare class With {
5251
+ type WithResult<T extends PickQueryWithDataColumnTypes, Name extends string, Q extends PickQueryResult> = {
5252
+ [K in keyof T]: K extends 'withData' ? {
5253
+ [K in keyof T['withData'] | Name]: K extends Name ? {
5254
+ table: Name;
5255
+ shape: Q['result'];
5256
+ } : K extends keyof T['withData'] ? T['withData'][K] : never;
5257
+ } : T[K];
5258
+ };
5259
+ type WithSqlResult<T extends PickQueryWithDataColumnTypes, Name extends string, Shape extends ColumnsShapeBase> = {
5260
+ [K in keyof T]: K extends 'withData' ? {
5261
+ [K in Name | keyof T['withData']]: K extends Name ? {
5262
+ table: Name;
5263
+ shape: Shape;
5264
+ } : K extends keyof T['withData'] ? T['withData'][K] : never;
5265
+ } : T[K];
5266
+ };
5267
+ declare class WithMethods {
5107
5268
  /**
5108
5269
  * Add Common Table Expression (CTE) to the query.
5109
5270
  *
@@ -5167,96 +5328,134 @@ declare class With {
5167
5328
  * .join('alias', 'alias.id', 'user.id')
5168
5329
  * .select('alias.id');
5169
5330
  * ```
5170
- *
5171
- * @param args - first argument is an alias for this CTE, other arguments can be column shape, query object, or raw SQL.
5172
5331
  */
5173
- with<T extends PickQueryWithData, Args extends WithArgs, Shape extends QueryColumns = WithShape<Args>>(this: T, ...args: Args): WithResult<T, Args, Shape>;
5332
+ with<T extends PickQueryWithDataColumnTypes, Name extends string, Q>(this: T, name: Name, query: Q | ((q: WithQueryBuilder<T>) => Q)): WithResult<T, Name, Q extends Query ? Q : never>;
5333
+ with<T extends PickQueryWithDataColumnTypes, Name extends string, Q extends Query>(this: T, name: Name, options: WithArgsOptions, query: Q | ((qb: WithQueryBuilder<T>) => Q)): WithResult<T, Name, Q>;
5334
+ withRecursive<T extends PickQueryWithDataColumnTypes, Name extends string, Q extends Query, Result = WithResult<T, Name, Q>>(this: T, name: Name, base: Q | ((qb: WithQueryBuilder<T>) => Q), recursive: (qb: {
5335
+ [K in keyof Result]: K extends 'result' ? Q['result'] : Result[K];
5336
+ }) => Query): Result;
5337
+ withRecursive<T extends PickQueryWithDataColumnTypes, Name extends string, Q extends Query, Result = WithResult<T, Name, Q>>(this: T, name: Name, options: WithRecursiveOptions, base: Q | ((qb: WithQueryBuilder<T>) => Q), recursive: (qb: {
5338
+ [K in keyof Result]: K extends 'result' ? Q['result'] : Result[K];
5339
+ }) => Query): Result;
5340
+ withSql<T extends PickQueryWithDataColumnTypes, Name extends string, Shape extends ColumnsShapeBase>(this: T, name: Name, options: WithOptions, shape: (t: T['columnTypes']) => Shape, expr: (q: T) => Expression): WithSqlResult<T, Name, Shape>;
5341
+ withSql<T extends PickQueryWithDataColumnTypes, Name extends string, Shape extends ColumnsShapeBase>(this: T, name: Name, shape: (t: T['columnTypes']) => Shape, expr: (q: T) => Expression): WithSqlResult<T, Name, Shape>;
5174
5342
  }
5175
5343
 
5176
5344
  type UnionArg<T extends PickQueryResult> = {
5177
5345
  result: {
5178
5346
  [K in keyof T['result']]: {
5179
- dataType: T['result'][K]['dataType'];
5347
+ queryType: T['result'][K]['queryType'];
5180
5348
  };
5181
5349
  };
5182
- } | Expression;
5350
+ } | ((q: T) => Expression);
5351
+ declare const _queryUnion: <T extends Query>(base: T, args: UnionArg<T>[], k: UnionKind) => T;
5183
5352
  declare class Union {
5184
5353
  /**
5185
- * Creates a union query, taking an array or a list of callbacks, builders, or raw statements to build the union statement, with optional boolean `wrap`.
5186
- * If the `wrap` parameter is true, the queries will be individually wrapped in parentheses.
5354
+ * Creates a union query, takes one or more queries or SQL expressions.
5187
5355
  *
5188
5356
  * ```ts
5189
- * SomeTable.select('id', 'name').union(
5190
- * [
5191
- * OtherTable.select('id', 'name'),
5192
- * sql`SELECT id, name FROM "thirdTable"`,
5193
- * ],
5194
- * true, // optional wrap parameter
5195
- * );
5357
+ * // The first query of the union
5358
+ * db.one
5359
+ * .select('id', 'name')
5360
+ * // add two more queries to the union
5361
+ * .union(
5362
+ * db.two.select('id', 'name'),
5363
+ * (q = q.sql`SELECT id, name FROM "thirdTable"`),
5364
+ * )
5365
+ * // sub-sequent `union` is equivalent to passing multiple queries into a single `union`
5366
+ * .union(db.three.select('id', 'name'));
5196
5367
  * ```
5197
5368
  *
5198
- * @param args - array of queries or raw SQLs
5199
- * @param wrap - provide `true` if you want the queries to be wrapped into parentheses
5369
+ * `order`, `limit`, `offset` are special, it matters if you place them **before** or **after** the `union`, it also have a meaning to place them before and after.
5370
+ *
5371
+ * ```ts
5372
+ * // order, limit, offset are applied ONLY to 'one'
5373
+ * db.one
5374
+ * .order('x')
5375
+ * .limit(1)
5376
+ * .offset(1)
5377
+ * // 'two' also has order, limit, and offset
5378
+ * .unionAll(db.two.order('y').limit(2).offset(2))
5379
+ * // sets order, limit, offset for all records
5380
+ * .order('z')
5381
+ * .limit(3)
5382
+ * .offset(3);
5383
+ * ```
5384
+ *
5385
+ * Equivalent SQL:
5386
+ *
5387
+ * ```sql
5388
+ * -- both union parts have their own order, limit, offset
5389
+ * ( SELECT * FROM one ORDER x ASC LIMIT 1 OFFSET 1 )
5390
+ * UNION ALL
5391
+ * ( SELECT * FROM two ORDER y ASC LIMIT 2 OFFSET 2 )
5392
+ * -- order, limit, offset of the whole query
5393
+ * ORDER BY z ASC LIMIT 3 OFFSET 3
5394
+ * ```
5395
+ *
5396
+ * All the listed methods have the same signature, they are only different by SQL keyword:
5397
+ *
5398
+ * - `union` - union of all queries, performs deduplication
5399
+ * - `unionAll` - `union` that allows duplicated rows
5400
+ * - `intersect` - get only rows that are present in all queries
5401
+ * - `intersectAll` - `intersect` that allows duplicated rows
5402
+ * - `except` - get only rows that are in the first query but not in the second
5403
+ * - `exceptAll` - `except` that allows duplicated rows
5404
+ *
5405
+ * @param args - array of queries or SQL expressions
5200
5406
  */
5201
- union<T extends PickQueryResult>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
5407
+ union<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
5202
5408
  /**
5203
- * Same as `union`, but allows duplicated rows.
5409
+ * Same as {@link union}, but allows duplicated rows.
5204
5410
  *
5205
- * @param args - array of queries or raw SQLs
5206
- * @param wrap - provide `true` if you want the queries to be wrapped into parentheses
5411
+ * @param args - array of queries or SQL expressions
5207
5412
  */
5208
- unionAll<T extends PickQueryResult>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
5413
+ unionAll<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
5209
5414
  /**
5210
- * Same as `union`, but uses a `INTERSECT` SQL keyword instead
5415
+ * Same as {@link union}, but uses a `INTERSECT` SQL keyword instead
5211
5416
  *
5212
- * @param args - array of queries or raw SQLs
5213
- * @param wrap - provide `true` if you want the queries to be wrapped into parentheses
5417
+ * @param args - array of queries or SQL expressions
5214
5418
  */
5215
- intersect<T extends PickQueryResult>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
5419
+ intersect<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
5216
5420
  /**
5217
- * Same as `intersect`, but allows duplicated rows.
5421
+ * Same as {@link intersect}, but allows duplicated rows.
5218
5422
  *
5219
- * @param args - array of queries or raw SQLs
5220
- * @param wrap - provide `true` if you want the queries to be wrapped into parentheses
5423
+ * @param args - array of queries or SQL expressions
5221
5424
  */
5222
- intersectAll<T extends PickQueryResult>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
5425
+ intersectAll<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
5223
5426
  /**
5224
- * Same as `union`, but uses an `EXCEPT` SQL keyword instead
5427
+ * Same as {@link union}, but uses an `EXCEPT` SQL keyword instead
5225
5428
  *
5226
- * @param args - array of queries or raw SQLs
5227
- * @param wrap - provide `true` if you want the queries to be wrapped into parentheses
5429
+ * @param args - array of queries or SQL expressions
5228
5430
  */
5229
- except<T extends PickQueryResult>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
5431
+ except<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
5230
5432
  /**
5231
- * Same as `except`, but allows duplicated rows.
5433
+ * Same as {@link except}, but allows duplicated rows.
5232
5434
  *
5233
- * @param args - array of queries or raw SQLs
5234
- * @param wrap - provide `true` if you want the queries to be wrapped into parentheses
5435
+ * @param args - array of queries or SQL expressions
5235
5436
  */
5236
- exceptAll<T extends PickQueryResult>(this: T, args: UnionArg<T>[], wrap?: boolean): T;
5437
+ exceptAll<T extends PickQueryResult>(this: T, ...args: UnionArg<T>[]): T;
5237
5438
  }
5238
5439
 
5239
5440
  type UpdateSelf = {
5240
- [K in 'meta' | 'inputType' | 'relations' | 'shape' | 'result' | 'returnType' | keyof JsonModifiers]: Query[K];
5441
+ [K in 'inputType' | 'relations' | UpdateColumnArgKeys]: Query[K];
5241
5442
  };
5242
5443
  type UpdateData<T extends UpdateSelf> = {
5243
5444
  [K in keyof T['inputType']]?: UpdateColumn<T, K>;
5244
5445
  } & {
5245
5446
  [K in keyof T['relations']]?: UpdateRelationData<T, T['relations'][K]['relationConfig']>;
5246
5447
  };
5247
- type UpdateColumnArgKeys = keyof JsonModifiers | 'meta' | 'shape' | 'result' | 'returnType';
5248
- type UpdateColumnCallbackResult = JsonItem | ResultRelationQueryBase;
5249
- interface ResultRelationQueryBaseMeta extends QueryMetaBase {
5250
- kind: 'select';
5251
- }
5252
- interface ResultRelationQueryBase extends RelationQueryBase {
5253
- meta: ResultRelationQueryBaseMeta;
5448
+ type UpdateColumnArgKeys = keyof JsonModifiers | keyof ExpressionMethods | 'sql' | 'meta' | 'shape' | 'result' | 'returnType' | 'columnTypes';
5449
+ interface UpdateQueryOrExpression<T> extends QueryOrExpression<T> {
5450
+ meta: {
5451
+ kind: 'select';
5452
+ };
5254
5453
  }
5255
- type UpdateColumn<T extends UpdateSelf, Key extends keyof T['inputType']> = T['inputType'][Key] | Expression | {
5454
+ type UpdateColumn<T extends UpdateSelf, Key extends keyof T['inputType']> = T['inputType'][Key] | QueryOrExpression<T['inputType'][Key]> | {
5256
5455
  [K in keyof Query]: K extends 'then' ? QueryThen<T['inputType'][Key]> : Query[K];
5257
5456
  } | ((q: {
5258
5457
  [K in keyof T['relations'] | UpdateColumnArgKeys]: K extends keyof T['relations'] ? T['relations'][K] : K extends UpdateColumnArgKeys ? T[K] : never;
5259
- }) => UpdateColumnCallbackResult);
5458
+ }) => JsonItem | UpdateQueryOrExpression<T['inputType'][Key]>);
5260
5459
  type UpdateRelationData<T extends UpdateSelf, Rel extends RelationConfigBase> = QueryReturnsAll<T['returnType']> extends true ? Rel['dataForUpdate'] : Rel['one'] extends true ? Rel['dataForUpdate'] | Rel['dataForUpdateOne'] : Rel['dataForUpdate'] & Rel['dataForUpdateOne'];
5261
5460
  type UpdateArg<T extends UpdateSelf> = T['meta']['hasWhere'] extends true ? UpdateData<T> : never;
5262
5461
  type UpdateRawArgs<T extends UpdateSelf> = T['meta']['hasWhere'] extends true ? SQLQueryArgs : never;
@@ -5330,7 +5529,7 @@ declare class Update {
5330
5529
  * column1: 123,
5331
5530
  *
5332
5531
  * // use raw SQL to update the column
5333
- * column2: sql`2 + 2`,
5532
+ * column2: (q) => q.sql`2 + 2`,
5334
5533
  *
5335
5534
  * // use query that returns a single value
5336
5535
  * // returning multiple values will result in Postgres error
@@ -5439,7 +5638,7 @@ declare class Update {
5439
5638
  */
5440
5639
  update<T extends UpdateSelf>(this: T, arg: UpdateArg<T>): UpdateResult<T>;
5441
5640
  /**
5442
- * `updateRaw` is for updating records with raw expression.
5641
+ * `updateSql` is for updating records with raw expression.
5443
5642
  *
5444
5643
  * The behavior is the same as a regular `update` method has:
5445
5644
  * `find` or `where` must precede calling this method,
@@ -5450,14 +5649,14 @@ declare class Update {
5450
5649
  * const value = 'new name';
5451
5650
  *
5452
5651
  * // update with SQL template string
5453
- * const updatedCount = await db.table.find(1).updateRaw`name = ${value}`;
5652
+ * const updatedCount = await db.table.find(1).updateSql`name = ${value}`;
5454
5653
  *
5455
5654
  * // or update with `sql` function:
5456
- * await db.table.find(1).updateRaw(sql`name = ${value}`);
5655
+ * await db.table.find(1).updateSql(sql`name = ${value}`);
5457
5656
  * ```
5458
5657
  * @param args - raw SQL via a template string or by using a `sql` method
5459
5658
  */
5460
- updateRaw<T extends UpdateSelf>(this: T, ...args: UpdateRawArgs<T>): UpdateResult<T>;
5659
+ updateSql<T extends UpdateSelf>(this: T, ...args: UpdateRawArgs<T>): UpdateResult<T>;
5461
5660
  /**
5462
5661
  * To make sure that at least one row was updated use `updateOrThrow`:
5463
5662
  *
@@ -6026,150 +6225,6 @@ declare class QueryUpsertOrCreate {
6026
6225
  orCreate<T extends UpsertThis, BT extends CreateBelongsToData<T>>(this: T, data: OrCreateArg<T, BT>): UpsertResult<T>;
6027
6226
  }
6028
6227
 
6029
- declare class SqlMethod<ColumnTypes> {
6030
- /**
6031
- * When there is a need to use a piece of raw SQL, use the `sql` exported from the `BaseTable` file, it is also attached to query objects for convenience.
6032
- *
6033
- * When selecting a custom SQL, specify a resulting type with `<generic>` syntax:
6034
- *
6035
- * ```ts
6036
- * import { sql } from './baseTable';
6037
- *
6038
- * const result: { num: number }[] = await db.table.select({
6039
- * num: sql<number>`random() * 100`,
6040
- * });
6041
- * ```
6042
- *
6043
- * In a situation when you want the result to be parsed, such as when returning a timestamp that you want to be parsed into a `Date` object, provide a column type in such a way:
6044
- *
6045
- * This example assumes that the `timestamp` column was overridden with `asDate` as shown in [Override column types](/guide/columns-overview#override-column-types).
6046
- *
6047
- * ```ts
6048
- * import { sql } from './baseTable';
6049
- *
6050
- * const result: { timestamp: Date }[] = await db.table.select({
6051
- * timestamp: sql`now()`.type((t) => t.timestamp()),
6052
- * });
6053
- * ```
6054
- *
6055
- * In some cases such as when using [from](/guide/orm-and-query-builder.html#from), setting column type via callback allows for special `where` operations:
6056
- *
6057
- * ```ts
6058
- * const subQuery = db.someTable.select({
6059
- * sum: (q) => q.sql`$a + $b`.type((t) => t.decimal()).values({ a: 1, b: 2 }),
6060
- * });
6061
- *
6062
- * // `gt`, `gte`, `min`, `lt`, `lte`, `max` in `where`
6063
- * // are allowed only for numeric columns:
6064
- * const result = await db.$from(subQuery).where({ sum: { gte: 5 } });
6065
- * ```
6066
- *
6067
- * Many query methods have a version suffixed with `Sql`, you can pass an SQL template literal directly to these methods.
6068
- * These methods are: `whereSql`, `whereNotSql`, `orderSql`, `havingSql`, `fromSql`, `findBySql`.
6069
- *
6070
- * ```ts
6071
- * await db.table.whereSql`"someValue" = random() * 100`;
6072
- * ```
6073
- *
6074
- * Interpolating values in template literals is completely safe:
6075
- *
6076
- * ```ts
6077
- * // get value from user-provided params
6078
- * const { value } = req.params;
6079
- *
6080
- * // SQL injection is prevented by a library, this is safe:
6081
- * await db.table.whereSql`column = ${value}`;
6082
- * ```
6083
- *
6084
- * In the example above, TS cannot check if the table has `column` column, or if there are joined tables that have such column which will lead to error.
6085
- * Instead, use the [column](/guide/sql-expressions#column) or [ref](/guide/sql-expressions#ref) to reference a column:
6086
- *
6087
- * ```ts
6088
- * // ids will be prefixed with proper table names, no ambiguity:
6089
- * db.table.join(db.otherTable, 'id', 'otherId').where`
6090
- * ${db.table.column('id')} = 1 AND
6091
- * ${db.otherTable.ref('id')} = 2
6092
- * `;
6093
- * ```
6094
- *
6095
- * SQL can be passed with a simple string, it's important to note that this is not safe to interpolate values in it.
6096
- *
6097
- * ```ts
6098
- * import { sql } from './baseTable';
6099
- *
6100
- * // no interpolation is okay
6101
- * await db.table.where(sql({ raw: 'column = random() * 100' }));
6102
- *
6103
- * // get value from user-provided params
6104
- * const { value } = req.params;
6105
- *
6106
- * // this is NOT safe, SQL injection is possible:
6107
- * await db.table.where(sql({ raw: `column = random() * ${value}` }));
6108
- * ```
6109
- *
6110
- * To inject values into `sql({ raw: '...' })` SQL strings, denote it with `$` in the string and provide `values` object.
6111
- *
6112
- * Use `$$` to provide column or/and table name (`column` or `ref` are preferable). Column names will be quoted so don't quote them manually.
6113
- *
6114
- * ```ts
6115
- * import { sql } from './baseTable';
6116
- *
6117
- * // get value from user-provided params
6118
- * const { value } = req.params;
6119
- *
6120
- * // this is SAFE, SQL injection are prevented:
6121
- * await db.table.where(
6122
- * sql<boolean>({
6123
- * raw: '$$column = random() * $value',
6124
- * values: {
6125
- * column: 'someTable.someColumn', // or simply 'column'
6126
- * one: value,
6127
- * two: 123,
6128
- * },
6129
- * }),
6130
- * );
6131
- * ```
6132
- *
6133
- * Summarizing:
6134
- *
6135
- * ```ts
6136
- * import { sql } from './baseTable';
6137
- *
6138
- * // simplest form:
6139
- * sql`key = ${value}`;
6140
- *
6141
- * // with resulting type:
6142
- * sql<boolean>`key = ${value}`;
6143
- *
6144
- * // with column type for select:
6145
- * sql`key = ${value}`.type((t) => t.boolean());
6146
- *
6147
- * // with column name via `column` method:
6148
- * sql`${db.table.column('column')} = ${value}`;
6149
- *
6150
- * // raw SQL string, not allowed to interpolate values:
6151
- * sql({ raw: 'random()' });
6152
- *
6153
- * // with resulting type and `raw` string:
6154
- * sql<number>({ raw: 'random()' });
6155
- *
6156
- * // with column name and a value in a `raw` string:
6157
- * sql({
6158
- * raw: `$$column = $value`,
6159
- * values: { column: 'columnName', value: 123 },
6160
- * });
6161
- *
6162
- * // combine template literal, column type, and values:
6163
- * sql`($one + $two) / $one`.type((t) => t.numeric()).values({ one: 1, two: 2 });
6164
- * ```
6165
- *
6166
- * @param args - template literal or an object { raw: string }
6167
- * @return object that has `type` and `values` methods
6168
- */
6169
- sql<T = unknown>(this: PickQueryColumnTypes, ...args: StaticSQLArgs): RawSQL<QueryColumn<T>, ColumnTypes>;
6170
- sql<T = unknown>(this: PickQueryColumnTypes, ...args: [DynamicSQLArg]): DynamicRawSQL<QueryColumn<T>, ColumnTypes>;
6171
- }
6172
-
6173
6228
  type QueryTransformFn<T extends Query> = (input: T['then'] extends QueryThen<infer Data> ? Data : never) => unknown;
6174
6229
  type QueryTransform<T extends QueryBase, Data> = {
6175
6230
  [K in keyof T]: K extends 'returnType' ? 'valueOrThrow' : K extends 'result' ? {
@@ -6282,7 +6337,7 @@ declare const _queryExec: <T extends Query>(q: T) => never;
6282
6337
  declare const _queryFindBy: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOne<WhereResult<T>>;
6283
6338
  declare const _queryFindByOptional: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOneOptional<WhereResult<T>>;
6284
6339
  declare const _queryRows: <T extends Query>(q: T) => SetQueryReturnsRows<T>;
6285
- interface QueryMethods<ColumnTypes> extends AsMethods, AggregateMethods, Select, From, Join, With, Union, JsonModifiers, JsonMethods, Create, Update, Delete, Transaction, For, Where, SearchMethods, Clear, Having, QueryLog, QueryHooks, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, SqlMethod<ColumnTypes>, TransformMethods, ScopeMethods, SoftDeleteMethods, ExpressionMethods {
6340
+ interface QueryMethods<ColumnTypes> extends AsMethods, AggregateMethods, Select, FromMethods, Join, WithMethods, Union, JsonModifiers, JsonMethods, Create, Update, Delete, Transaction, For, Where, SearchMethods, Clear, Having, QueryLog, QueryHooks, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, SqlMethod<ColumnTypes>, TransformMethods, ScopeMethods, SoftDeleteMethods, ExpressionMethods {
6286
6341
  }
6287
6342
  declare class QueryMethods<ColumnTypes> {
6288
6343
  /**
@@ -6690,10 +6745,7 @@ declare class QueryMethods<ColumnTypes> {
6690
6745
  * pets: (q) => q.pets.join().none(),
6691
6746
  * });
6692
6747
  *
6693
- * await db.user.join(
6694
- * (q) => q.pets.none(),
6695
- * (q) => q,
6696
- * );
6748
+ * await db.user.join((q) => q.pets.none());
6697
6749
  *
6698
6750
  * await db.user.join('pets', (q) => q.none());
6699
6751
  * ```
@@ -6936,6 +6988,8 @@ interface PickQueryColumnTypes {
6936
6988
  }
6937
6989
  interface PickQueryMetaResultRelationsWindowsColumnTypes extends PickQueryMetaResultRelationsWindows, PickQueryColumnTypes {
6938
6990
  }
6991
+ interface PickQueryWithDataColumnTypes extends PickQueryWithData, PickQueryColumnTypes {
6992
+ }
6939
6993
  interface PickQueryMetaTable extends PickQueryMeta, PickQueryTable {
6940
6994
  }
6941
6995
  interface PickQueryMetaTableShape extends PickQueryMetaTable, PickQueryShape {
@@ -7114,12 +7168,6 @@ type SetQueryTableAlias<T extends PickQueryMetaTableShape, As extends string> =
7114
7168
  } : T['meta'][K];
7115
7169
  } : T[K];
7116
7170
  };
7117
- type SetQueryWith<T, WithData> = {
7118
- [K in keyof T]: K extends 'withData' ? WithData : T[K];
7119
- };
7120
- type AddQueryWith<T extends PickQueryWithData, With extends WithDataItem> = SetQueryWith<T, {
7121
- [K in keyof T['withData'] | With['table']]: K extends With['table'] ? With : K extends keyof T['withData'] ? T['withData'][K] : never;
7122
- }>;
7123
7171
  interface QueryOrExpression<T> {
7124
7172
  result: {
7125
7173
  value: QueryColumn<T>;
@@ -7788,4 +7836,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
7788
7836
  */
7789
7837
  declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
7790
7838
 
7791
- export { Adapter, AdapterConfig, AdapterOptions, AddQueryDefaults, AddQuerySelect, AddQueryWith, AfterHook, AggregateMethods, AggregateOptions, AliasOrTable, ArrayColumn, ArrayColumnValue, ArrayData, AsMethods, AsQueryArg, BaseOperators, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanQueryColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ClearStatement, CloneSelfKeys, ColumnData, ColumnExpression, ColumnFromDbParams, ColumnInfoQueryData, ColumnOperators, ColumnRefExpression, ColumnType, ColumnsByType, ColumnsShape, ColumnsShapeToNullableObject, ColumnsShapeToObject, ColumnsShapeToObjectArray, ColumnsShapeToPluck, CommonQueryData, ComputedColumnsBase, CopyOptions, CopyQueryData, Create, CreateBelongsToData, CreateColumn, CreateCtx, CreateData, CreateKind, CreateMethodsNames, CreateRelationsData, CreateRelationsDataOmittingFKeys, CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, DbDomainArg, DbDomainArgRecord, DbExtension, DbOptions, DbResult, DbSharedOptions, DbTableConstructor, DbTableOptionScopes, DbTableOptions, DecimalColumn, DecimalColumnData, DefaultColumnTypes, DefaultSchemaConfig, Delete, DeleteArgs, DeleteMethodsNames, DeleteQueryData, DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, ExpressionOutput, FnExpression, FnExpressionArgs, FnExpressionArgsPairs, FnExpressionArgsValue, For, From, FromArg, FromQuerySelf, FromResult, GetArg, GetColumnInfo, GetQueryResult, GetResult, GetResultOptional, GetStringArg, GroupArg, Having, HavingItem, HookAction, HookSelect, IdentityColumn, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsolationLevel, JSONColumn, JSONTextColumn, Join, JoinArgs, JoinCallback, JoinFirstArg, JoinItem, JoinItemArgs, JoinLateralCallback, JoinLateralItem, JoinLateralResult, JoinOverrides, JoinQueryBuilder, JoinQueryMethod, JoinResult, JoinedParsers, JoinedShapes, JsonItem, JsonMethods, JsonModifiers, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MapTableScopesOption, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NoPrimaryKeyOption, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumnData, OnConflictMerge, OnConflictQueryBuilder, OnConflictSet, OnConflictTarget, OnMethods, Operator, Operators, OperatorsAny, OperatorsArray, OperatorsBoolean, OperatorsDate, OperatorsJson, OperatorsNumber, OperatorsText, OperatorsTime, OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, OrderArg, OrderArgSelf, OrderArgs, OrderItem, OrderTsQueryConfig, Over, PathColumn, PickColumnData, PickQueryBaseQuery, PickQueryColumnTypes, PickQueryDataShapeAndJoinedShapes, PickQueryInternal, PickQueryMetaRelations, PickQueryMetaResultRelations, PickQueryMetaResultRelationsWindows, PickQueryMetaResultRelationsWindowsColumnTypes, PickQueryMetaResultRelationsWithDataReturnType, PickQueryMetaResultRelationsWithDataReturnTypeShape, PickQueryMetaResultReturnTypeWithDataWindows, PickQueryMetaResultReturnTypeWithDataWindowsTable, PickQueryMetaShapeRelationsWithData, PickQueryMetaTable, PickQueryMetaTableShape, PickQueryMetaTableShapeReturnTypeWithData, PickQueryMetaWithData, PickQueryQ, PickQueryQAndBaseQuery, PickQueryQAndInternal, PickQueryRelations, PickQueryRelationsWithData, PickQueryShapeResultSinglePrimaryKey, PickQueryShapeSinglePrimaryKey, PickQuerySinglePrimaryKey, PickQueryWindows, PickQueryWithData, PointColumn, PolygonColumn, Query, QueryAfterHook, QueryArraysResult, QueryBase, QueryBaseThen, QueryBeforeHook, QueryData, QueryDataFromItem, QueryDataJoinTo, QueryDefaultReturnData, QueryError, QueryErrorName, QueryGet, QueryGetSelf, QueryHelperResult, QueryHookSelect, QueryHooks, QueryInternal, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMetaHasSelect, QueryMetaHasWhere, QueryMethods, QueryOrExpression, QueryOrExpressionBooleanOrNullResult, QueryResult, QueryReturnsAll, QueryScopeData, QueryScopes, QuerySourceItem, QueryTransform, QueryTransformFn, QueryUpsertOrCreate, QueryWithComputed, QueryWithTable, RawSQL, RealColumn, RecordOfColumnsShapeBase, RefExpression, RelationConfigBase, RelationConfigDataForCreate, RelationJoinQuery, RelationQuery, RelationQueryBase, RelationsBase, SearchArg, SearchMethods, SearchWeight, SearchWeightRecord, Select, SelectArg, SelectAs, SelectItem, SelectQueryData, SelectSubQueryResult, SelectableFromShape, SelectableOfType, SelectableOrExpression, SelectableOrExpressionOfType, SerialColumn, SerialColumnData, SetQueryKind, SetQueryKindResult, SetQueryReturnsAll, SetQueryReturnsAllKind, SetQueryReturnsAllKindResult, SetQueryReturnsColumnInfo, SetQueryReturnsColumnKind, SetQueryReturnsColumnKindResult, SetQueryReturnsColumnOptional, SetQueryReturnsColumnOrThrow, SetQueryReturnsOne, SetQueryReturnsOneKind, SetQueryReturnsOneKindResult, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsPluckColumn, SetQueryReturnsPluckColumnKind, SetQueryReturnsPluckColumnKindResult, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValueOptional, SetQueryReturnsValueOrThrow, SetQueryReturnsVoid, SetQueryReturnsVoidKind, SetQueryTableAlias, SetQueryWith, ShapeColumnPrimaryKeys, ShapeUniqueColumns, SimpleJoinItem, SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, SortDir, SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, TableDataFn, TableDataInput, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableDataMethods, TextBaseColumn, TextColumn, TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, ToSQLCtx, ToSQLOptions, ToSQLQuery, Transaction, TransactionAdapter, TransactionOptions, TransformMethods, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnionKind, UniqueConstraints, UniqueQueryTypeOrExpression, UniqueTableDataItem, UnknownColumn, Update, UpdateArg, UpdateCtx, UpdateCtxCollect, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdateSelf, UpdatedAtDataInjector, UpsertArg, UpsertResult, UpsertThis, VarCharColumn, VirtualColumn, Where, WhereArg, WhereArgs, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereNotArgs, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WhereSearchItem, WhereSearchResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowItem, With, WithDataBase, WithDataItem, WithDataItems, WithItem, WithOptions, WrapQueryArg, XMLColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotSql, _queryWhereSql, addComputedColumns, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseResult, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
7839
+ export { Adapter, AdapterConfig, AdapterOptions, AddQueryDefaults, AddQuerySelect, AfterHook, AggregateMethods, AggregateOptions, AliasOrTable, ArrayColumn, ArrayColumnValue, ArrayData, AsMethods, AsQueryArg, BaseOperators, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanQueryColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ClearStatement, CloneSelfKeys, ColumnData, ColumnExpression, ColumnFromDbParams, ColumnInfoQueryData, ColumnOperators, ColumnRefExpression, ColumnType, ColumnsByType, ColumnsShape, ColumnsShapeToNullableObject, ColumnsShapeToObject, ColumnsShapeToObjectArray, ColumnsShapeToPluck, CommonQueryData, ComputedColumnsBase, CopyOptions, CopyQueryData, Create, CreateBelongsToData, CreateColumn, CreateCtx, CreateData, CreateKind, CreateMethodsNames, CreateRelationsData, CreateRelationsDataOmittingFKeys, CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, DbDomainArg, DbDomainArgRecord, DbExtension, DbOptions, DbResult, DbSharedOptions, DbTableConstructor, DbTableOptionScopes, DbTableOptions, DecimalColumn, DecimalColumnData, DefaultColumnTypes, DefaultSchemaConfig, Delete, DeleteArgs, DeleteMethodsNames, DeleteQueryData, DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, ExpressionOutput, FnExpression, FnExpressionArgs, FnExpressionArgsPairs, FnExpressionArgsValue, For, FromArg, FromMethods, FromQuerySelf, FromResult, GetArg, GetColumnInfo, GetQueryResult, GetResult, GetResultOptional, GetStringArg, GroupArg, Having, HavingItem, HookAction, HookSelect, IdentityColumn, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsolationLevel, JSONColumn, JSONTextColumn, Join, JoinArgs, JoinCallback, JoinFirstArg, JoinItem, JoinItemArgs, JoinLateralCallback, JoinLateralItem, JoinLateralResult, JoinOverrides, JoinQueryBuilder, JoinQueryMethod, JoinResult, JoinedParsers, JoinedShapes, JsonItem, JsonMethods, JsonModifiers, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MapTableScopesOption, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NoPrimaryKeyOption, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumnData, OnConflictMerge, OnConflictQueryBuilder, OnConflictSet, OnConflictTarget, OnMethods, Operator, Operators, OperatorsAny, OperatorsArray, OperatorsBoolean, OperatorsDate, OperatorsJson, OperatorsNumber, OperatorsText, OperatorsTime, OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, OrderArg, OrderArgSelf, OrderArgs, OrderItem, OrderTsQueryConfig, Over, PathColumn, PickColumnData, PickQueryBaseQuery, PickQueryColumnTypes, PickQueryDataShapeAndJoinedShapes, PickQueryInternal, PickQueryMetaRelations, PickQueryMetaResultRelations, PickQueryMetaResultRelationsWindows, PickQueryMetaResultRelationsWindowsColumnTypes, PickQueryMetaResultRelationsWithDataReturnType, PickQueryMetaResultRelationsWithDataReturnTypeShape, PickQueryMetaResultReturnTypeWithDataWindows, PickQueryMetaResultReturnTypeWithDataWindowsTable, PickQueryMetaShapeRelationsWithData, PickQueryMetaTable, PickQueryMetaTableShape, PickQueryMetaTableShapeReturnTypeWithData, PickQueryMetaWithData, PickQueryQ, PickQueryQAndBaseQuery, PickQueryQAndInternal, PickQueryRelations, PickQueryRelationsWithData, PickQueryShapeResultSinglePrimaryKey, PickQueryShapeSinglePrimaryKey, PickQuerySinglePrimaryKey, PickQueryWindows, PickQueryWithData, PickQueryWithDataColumnTypes, PointColumn, PolygonColumn, Query, QueryAfterHook, QueryArraysResult, QueryBase, QueryBaseThen, QueryBeforeHook, QueryData, QueryDataFromItem, QueryDataJoinTo, QueryDefaultReturnData, QueryError, QueryErrorName, QueryGet, QueryGetSelf, QueryHelperResult, QueryHookSelect, QueryHooks, QueryInternal, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMetaHasSelect, QueryMetaHasWhere, QueryMethods, QueryOrExpression, QueryOrExpressionBooleanOrNullResult, QueryResult, QueryReturnsAll, QueryScopeData, QueryScopes, QuerySourceItem, QueryTransform, QueryTransformFn, QueryUpsertOrCreate, QueryWithComputed, QueryWithTable, RawSQL, RealColumn, RecordOfColumnsShapeBase, RefExpression, RelationConfigBase, RelationConfigDataForCreate, RelationJoinQuery, RelationQuery, RelationQueryBase, RelationsBase, SearchArg, SearchMethods, SearchWeight, SearchWeightRecord, Select, SelectArg, SelectAs, SelectItem, SelectQueryData, SelectSubQueryResult, SelectableFromShape, SelectableOfType, SelectableOrExpression, SelectableOrExpressionOfType, SerialColumn, SerialColumnData, SetQueryKind, SetQueryKindResult, SetQueryReturnsAll, SetQueryReturnsAllKind, SetQueryReturnsAllKindResult, SetQueryReturnsColumnInfo, SetQueryReturnsColumnKind, SetQueryReturnsColumnKindResult, SetQueryReturnsColumnOptional, SetQueryReturnsColumnOrThrow, SetQueryReturnsOne, SetQueryReturnsOneKind, SetQueryReturnsOneKindResult, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsPluckColumn, SetQueryReturnsPluckColumnKind, SetQueryReturnsPluckColumnKindResult, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValueOptional, SetQueryReturnsValueOrThrow, SetQueryReturnsVoid, SetQueryReturnsVoidKind, SetQueryTableAlias, ShapeColumnPrimaryKeys, ShapeUniqueColumns, SimpleJoinItem, SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, SortDir, SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, TableDataFn, TableDataInput, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableDataMethods, TextBaseColumn, TextColumn, TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, ToSQLCtx, ToSQLOptions, ToSQLQuery, Transaction, TransactionAdapter, TransactionOptions, TransformMethods, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnionKind, UnionSet, UniqueConstraints, UniqueQueryTypeOrExpression, UniqueTableDataItem, UnknownColumn, Update, UpdateArg, UpdateCtx, UpdateCtxCollect, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdateSelf, UpdatedAtDataInjector, UpsertArg, UpsertResult, UpsertThis, VarCharColumn, VirtualColumn, Where, WhereArg, WhereArgs, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereNotArgs, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WhereSearchItem, WhereSearchResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowItem, WithArgsOptions, WithDataBase, WithDataItem, WithDataItems, WithItem, WithMethods, WithOptions, WithQueryBuilder, WithRecursiveOptions, WithResult, WithSqlResult, WrapQueryArg, XMLColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotSql, _queryWhereSql, addComputedColumns, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseResult, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };