pqb 0.30.1 → 0.30.3

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
@@ -1,5 +1,5 @@
1
1
  import * as orchid_core from 'orchid-core';
2
- import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, Sql, RecordUnknown, RecordKeyTrue, EmptyObject, QueryBaseCommon, QueryColumns, QueryMetaBase, QueryReturnType, QueryThen, Expression, QueryColumn, MaybeArray, SelectableBase, TemplateLiteralArgs, PickOutputTypeAndOperators, PickQueryResult, OperatorToSQL, ColumnsShapeBase, ColumnsParsers, RecordString, PickQueryTable, FnUnknownToUnknown, ExpressionChain, getValueKey, PickQueryShape, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, PickQueryMetaShape, PickQueryTableMetaResultShape, QueryColumnBooleanOrNull, SQLQueryArgs, ColumnSchemaConfig, DateColumnData, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, StaticSQLArgs, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ParseColumn, EncodeColumn, PickQueryMetaResult, QueryColumnsInit, DefaultSelectColumns, CoreQueryScopes, DbBase, QueryCatch, TransactionState, ColumnTypeBase, PickQueryMetaResultWindows, CoreBaseOperators, PickQueryUniqueProperties, IsQuery, PickQueryMetaShapeResultReturnType, MergeObjects, ExpressionData, PickQueryResultUniqueColumns, QueryInternalBase, PickQueryReturnType, PickType, ColumnShapeOutput, PickOutputType, PickQueryMetaReturnType, UniqueColumn, TimestampHelpers, Codes, ColumnDataCheckBase, PickQueryTableMetaShape } from 'orchid-core';
2
+ import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, Sql, RecordUnknown, RecordKeyTrue, EmptyObject, QueryBaseCommon, QueryColumns, QueryMetaBase, QueryReturnType, QueryThen, Expression, QueryColumn, MaybeArray, SelectableBase, TemplateLiteralArgs, PickOutputTypeAndOperators, PickQueryResult, OperatorToSQL, ColumnsShapeBase, ColumnsParsers, RecordString, PickQueryTable, FnUnknownToUnknown, ExpressionChain, getValueKey, PickQueryShape, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, PickQueryMetaShape, PickQueryTableMetaResultShape, QueryColumnBooleanOrNull, SQLQueryArgs, ColumnSchemaConfig, DateColumnData, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, StaticSQLArgs, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ParseColumn, EncodeColumn, PickQueryMetaResult, QueryColumnsInit, DefaultSelectColumns, CoreQueryScopes, DbBase, QueryCatch, TransactionState, ColumnTypeBase, PickQueryMetaResultWindows, CoreBaseOperators, PickQueryUniqueProperties, IsQuery, PickQueryMetaShapeResultReturnType, MergeObjects, ExpressionData, ValExpression, PickOutputType, PickQueryResultUniqueColumns, QueryInternalBase, PickQueryReturnType, PickType, ColumnShapeOutput, PickQueryMetaReturnType, UniqueColumn, TimestampHelpers, Codes, ColumnDataCheckBase, PickQueryTableMetaShape } from 'orchid-core';
3
3
  import { PoolConfig, Pool, PoolClient } from 'pg';
4
4
  import { inspect } from 'node:util';
5
5
  import { AsyncLocalStorage } from 'node:async_hooks';
@@ -796,15 +796,14 @@ declare class Join {
796
796
  * profile: (q) => q.profile,
797
797
  * });
798
798
  *
799
- * // select posts with counts of comments, order by comments count
799
+ * // select posts with counts of comments, filter and order by comments count
800
800
  * // result type is Array<Post & { commentsCount: number }>
801
801
  * await db.post
802
802
  * .select('*', {
803
803
  * commentsCount: (q) => q.comments.count(),
804
804
  * })
805
- * .order({
806
- * commentsCount: 'DESC',
807
- * });
805
+ * .where({ commentsCount: { gt: 10 } })
806
+ * .order({ commentsCount: 'DESC' });
808
807
  *
809
808
  * // select authors with array of their book titles
810
809
  * // result type is Array<Author & { books: string[] }>
@@ -1055,7 +1054,8 @@ declare class Join {
1055
1054
  * ```ts
1056
1055
  * db.user.join(
1057
1056
  * db.message,
1058
- * db.user.sql`lower("message"."text") = lower("user"."name")`,
1057
+ * // `sql` can be imported from your `BaseTable` file
1058
+ * sql`lower("message"."text") = lower("user"."name")`,
1059
1059
  * );
1060
1060
  * ```
1061
1061
  *
@@ -1064,16 +1064,16 @@ declare class Join {
1064
1064
  * ```ts
1065
1065
  * db.user.join(
1066
1066
  * db.message,
1067
- * db.user.sql`lower("message"."text")`,
1068
- * db.user.sql`lower("user"."name")`,
1067
+ * sql`lower("message"."text")`,
1068
+ * sql`lower("user"."name")`,
1069
1069
  * );
1070
1070
  *
1071
1071
  * // with operator:
1072
1072
  * db.user.join(
1073
1073
  * db.message,
1074
- * db.user.sql`lower("message"."text")`,
1074
+ * sql`lower("message"."text")`,
1075
1075
  * '!=',
1076
- * db.user.sql`lower("user"."name")`,
1076
+ * sql`lower("user"."name")`,
1077
1077
  * );
1078
1078
  * ```
1079
1079
  *
@@ -1087,7 +1087,7 @@ declare class Join {
1087
1087
  * 'message.userId': 'user.id',
1088
1088
  *
1089
1089
  * // value can be a raw SQL expression:
1090
- * text: db.user.sql`lower("user"."name")`,
1090
+ * text: sql`lower("user"."name")`,
1091
1091
  * });
1092
1092
  * ```
1093
1093
  *
@@ -1516,7 +1516,8 @@ declare class Where {
1516
1516
  * },
1517
1517
  *
1518
1518
  * // where column equals to raw SQL
1519
- * column: db.table.sql`sql expression`,
1519
+ * // import `sql` from your `BaseTable`
1520
+ * column: sql`sql expression`,
1520
1521
  * });
1521
1522
  * ```
1522
1523
  *
@@ -1565,12 +1566,7 @@ declare class Where {
1565
1566
  * `where` supports raw SQL:
1566
1567
  *
1567
1568
  * ```ts
1568
- * db.table.where(db.table.sql`a = b`);
1569
- *
1570
- * // or
1571
- * import { raw } from 'orchid-orm';
1572
- *
1573
- * db.table.where(raw`a = b`);
1569
+ * db.table.where(sql`a = b`);
1574
1570
  * ```
1575
1571
  *
1576
1572
  * `where` can accept a callback with a specific query builder containing all "where" methods such as `where`, `orWhere`, `whereNot`, `whereIn`, `whereExists`:
@@ -1591,7 +1587,7 @@ declare class Where {
1591
1587
  * db.table.where(
1592
1588
  * { id: 1 },
1593
1589
  * db.table.where({ name: 'John' }),
1594
- * db.table.sql`a = b`,
1590
+ * sql`a = b`,
1595
1591
  * );
1596
1592
  * ```
1597
1593
  *
@@ -1704,8 +1700,6 @@ declare class Where {
1704
1700
  * All column operators can take a value of the same type as the column, a sub-query, or a raw SQL expression:
1705
1701
  *
1706
1702
  * ```ts
1707
- * import { sql } from 'orchid-orm';
1708
- *
1709
1703
  * db.table.where({
1710
1704
  * numericColumn: {
1711
1705
  * // lower than 5
@@ -1754,7 +1748,7 @@ declare class Where {
1754
1748
  * // WHERE "column" IN (SELECT "column" FROM "otherTable")
1755
1749
  * in: OtherTable.select('column'),
1756
1750
  *
1757
- * in: db.table.sql`('a', 'b')`,
1751
+ * in: sql`('a', 'b')`,
1758
1752
  * },
1759
1753
  * });
1760
1754
  * ```
@@ -1801,7 +1795,7 @@ declare class Where {
1801
1795
  * between: [1, 10],
1802
1796
  *
1803
1797
  * // sub-query and raw SQL expression
1804
- * between: [OtherTable.select('column').take(), db.table.sql`2 + 2`],
1798
+ * between: [OtherTable.select('column').take(), sql`2 + 2`],
1805
1799
  * },
1806
1800
  * });
1807
1801
  * ```
@@ -1888,15 +1882,7 @@ declare class Where {
1888
1882
  * Use a custom SQL expression in `WHERE` statement:
1889
1883
  *
1890
1884
  * ```ts
1891
- * db.table.where`a = b`;
1892
- *
1893
- * // or
1894
- * db.table.where(db.table.sql`a = b`);
1895
- *
1896
- * // or
1897
- * import { raw } from 'orchid-orm';
1898
- *
1899
- * db.table.where(raw`a = b`);
1885
+ * db.table.whereSql`a = b`;
1900
1886
  * ```
1901
1887
  *
1902
1888
  * @param args - SQL expression
@@ -1919,10 +1905,10 @@ declare class Where {
1919
1905
  */
1920
1906
  whereNot<T extends PickQueryMetaRelations>(this: T, ...args: WhereNotArgs<T>): WhereResult<T>;
1921
1907
  /**
1922
- * `whereNot` version accepting SQL expression:
1908
+ * `whereNotSql` is a version of `whereNot` accepting SQL expression:
1923
1909
  *
1924
1910
  * ```ts
1925
- * db.table.whereNot`sql expression`
1911
+ * db.table.whereNotSql`sql expression`
1926
1912
  * ```
1927
1913
  *
1928
1914
  * @param args - SQL expression
@@ -1990,7 +1976,7 @@ declare class Where {
1990
1976
  * It supports raw SQL expression:
1991
1977
  *
1992
1978
  * ```ts
1993
- * db.table.whereIn(['id', 'name'], db.table.sql`((1, 'one'), (2, 'two'))`);
1979
+ * db.table.whereIn(['id', 'name'], sql`((1, 'one'), (2, 'two'))`);
1994
1980
  * ```
1995
1981
  */
1996
1982
  whereIn<T extends PickQueryMetaRelations, Column extends WhereInColumn<T>>(this: T, ...args: [column: Column, values: WhereInValues<T, Column>] | [arg: WhereInArg<T>]): WhereResult<T>;
@@ -3233,41 +3219,6 @@ type StringColumn = QueryColumn<string, OperatorsText>;
3233
3219
  type StringNullable = QueryColumn<string | null, OperatorsText>;
3234
3220
  type NullableStringReturn<T> = SetQueryReturnsColumnOrThrow<T, StringNullable> & OperatorsText;
3235
3221
  declare class AggregateMethods {
3236
- /**
3237
- * `fn` allows to call an arbitrary SQL function.
3238
- *
3239
- * For example, calling `sqrt` function to get a square root from some numeric column:
3240
- *
3241
- * ```ts
3242
- * const q = await User.select({
3243
- * // todo: use type callback instead of generic type
3244
- * sqrt: (q) => q.fn<number>('sqrt', ['numericColumn']),
3245
- * }).take();
3246
- *
3247
- * q.sqrt; // has type `number` just as provided
3248
- * ```
3249
- *
3250
- * If this is an aggregate function, you can specify aggregation options via third parameter.
3251
- *
3252
- * Forth parameter is for runtime column type. When specified, allows to chain the function with the column operators:
3253
- *
3254
- * ```ts
3255
- * const q = await User.select({
3256
- * // chain `sqrt("numericColumn")` with the "greater than 5"
3257
- * sqrtIsGreaterThan5: (q) => q.fn('sqrt', ['numericColumn'], {}, (t) => t.float()).gt(5),
3258
- * }).take();
3259
- *
3260
- * // Return type is boolean | null
3261
- * // todo: it should be just boolean if the column is not nullable, but for now it's always nullable
3262
- * q.sqrtIsGreaterThan5
3263
- * ```
3264
- *
3265
- * @param fn
3266
- * @param args
3267
- * @param options
3268
- * @param type
3269
- */
3270
- fn<T extends PickQueryMetaResultRelationsWindowsColumnTypes, Type = unknown, C extends QueryColumn = QueryColumn<Type>>(this: T, fn: string, args: SelectableOrExpression<T>[], options?: AggregateOptions<T>, type?: (t: T['columnTypes']) => C): SetQueryReturnsColumnOrThrow<T, C> & C['operators'];
3271
3222
  /**
3272
3223
  * Use `exists()` to check if there is at least one record-matching condition.
3273
3224
  *
@@ -3514,7 +3465,7 @@ declare class AggregateMethods {
3514
3465
  * // select a column with alias
3515
3466
  * nameAlias: 'name',
3516
3467
  * // select raw SQL with alias
3517
- * foo: db.table.sql<string>`"bar" || "baz"`,
3468
+ * foo: sql<string>`"bar" || "baz"`,
3518
3469
  * },
3519
3470
  * aggregateOptions,
3520
3471
  * );
@@ -3524,7 +3475,7 @@ declare class AggregateMethods {
3524
3475
  * object: (q) =>
3525
3476
  * q.jsonObjectAgg({
3526
3477
  * nameAlias: 'name',
3527
- * foo: db.table.sql<string>`"bar" || "baz"`,
3478
+ * foo: sql<string>`"bar" || "baz"`,
3528
3479
  * }),
3529
3480
  * });
3530
3481
  * ```
@@ -3823,7 +3774,7 @@ declare class Create {
3823
3774
  *
3824
3775
  * await db.table.create({
3825
3776
  * // raw SQL
3826
- * column1: db.table.sql`'John' | 'Doe'`,
3777
+ * column1: sql`'John' || ' ' || 'Doe'`,
3827
3778
  *
3828
3779
  * // query that returns a single value
3829
3780
  * // returning multiple values will result in Postgres error
@@ -3878,7 +3829,7 @@ declare class Create {
3878
3829
  * ```ts
3879
3830
  * const oneRecord = await db.table.createRaw({
3880
3831
  * columns: ['name', 'amount'],
3881
- * values: db.table.sql`'name', random()`,
3832
+ * values: sql`'name', random()`,
3882
3833
  * });
3883
3834
  * ```
3884
3835
  *
@@ -3903,7 +3854,7 @@ declare class Create {
3903
3854
  * ```ts
3904
3855
  * const manyRecords = await db.table.createManyRaw({
3905
3856
  * columns: ['name', 'amount'],
3906
- * values: [db.table.sql`'one', 2`, db.table.sql`'three', 4`],
3857
+ * values: [sql`'one', 2`, sql`'three', 4`],
3907
3858
  * });
3908
3859
  * ```
3909
3860
  *
@@ -4049,11 +4000,11 @@ declare class Create {
4049
4000
  * // raw SQL expression:
4050
4001
  * db.table
4051
4002
  * .create(data)
4052
- * .onConfict(db.table.sql`(email) where condition`)
4003
+ * .onConfict(sql`(email) where condition`)
4053
4004
  * .merge();
4054
4005
  * ```
4055
4006
  *
4056
- * You can use the db.table.sql function in onConflict.
4007
+ * You can use the `sql` function exported from your `BaseTable` file in onConflict.
4057
4008
  * It can be useful to specify a condition when you have a partial index:
4058
4009
  *
4059
4010
  * ```ts
@@ -4064,7 +4015,7 @@ declare class Create {
4064
4015
  * active: true,
4065
4016
  * })
4066
4017
  * // ignore only when having conflicting email and when active is true.
4067
- * .onConflict(db.table.sql`(email) where active`)
4018
+ * .onConflict(sql`(email) where active`)
4068
4019
  * .ignore();
4069
4020
  * ```
4070
4021
  *
@@ -4150,7 +4101,7 @@ declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflic
4150
4101
  * db.table
4151
4102
  * .create(data)
4152
4103
  * .onConflict()
4153
- * .set(db.table.sql`raw SQL expression`);
4104
+ * .set(sql`raw SQL expression`);
4154
4105
  *
4155
4106
  * // update records only on certain conditions
4156
4107
  * db.table
@@ -4345,7 +4296,6 @@ declare class From {
4345
4296
  * ```ts
4346
4297
  * const value = 123;
4347
4298
  * db.table.fromSql`value = ${value}`;
4348
- * db.table.fromSql(db.table.sql`value = ${value}`);
4349
4299
  * ```
4350
4300
  *
4351
4301
  * @param args - SQL expression
@@ -4370,16 +4320,20 @@ declare class From {
4370
4320
 
4371
4321
  declare class QueryGet {
4372
4322
  /**
4373
- * `.get` returns a single value, it will add `LIMIT 1` to the query, and accepts a column name or a raw expression.
4374
- * It will throw `NotFoundError` when not found.
4323
+ * `.get` returns a single value, adds `LIMIT 1` to the query, and accepts a column name or a raw SQL expression.
4324
+ *
4325
+ * `get` throws a `NotFoundError` when not found, and `getOptional` returns `undefined`.
4375
4326
  *
4376
4327
  * ```ts
4377
4328
  * import { NumberColumn } from 'orchid-orm';
4329
+ * import { sql } from './baseTable';
4378
4330
  *
4379
4331
  * const firstName: string = await db.table.get('name');
4380
4332
  *
4381
- * const rawResult: number = await db.table.get(
4382
- * db.table.sql((t) => t.integer())`1 + 1`,
4333
+ * const rawResult: number = await db.table.get(sql((t) => t.integer())`1 + 1`);
4334
+ *
4335
+ * const firstNameOptional: string | undefined = await db.table.getOptional(
4336
+ * 'name',
4383
4337
  * );
4384
4338
  * ```
4385
4339
  *
@@ -4461,7 +4415,7 @@ declare class Having {
4461
4415
  * Provide SQL expression for the `HAVING` SQL statement:
4462
4416
  *
4463
4417
  * ```ts
4464
- * db.table.having`count(*) >= ${10}`;
4418
+ * db.table.havingSql`count(*) >= ${10}`;
4465
4419
  * ```
4466
4420
  *
4467
4421
  * @param args - SQL expression
@@ -4809,19 +4763,6 @@ declare class MergeQueryMethods {
4809
4763
  merge<T extends Query, Q extends Query>(this: T, q: Q): MergeQuery<T, Q>;
4810
4764
  }
4811
4765
 
4812
- declare const queryMethodByReturnType: {
4813
- [K in QueryReturnType]: 'query' | 'arrays';
4814
- };
4815
- type Resolve = (result: any) => any;
4816
- type Reject = (error: any) => any;
4817
- declare class Then {
4818
- then: (this: Query, resolve?: Resolve, reject?: Reject) => Promise<unknown>;
4819
- catch(this: Query, fn: (reason: any) => unknown): Promise<unknown>;
4820
- }
4821
- declare const handleResult: CommonQueryData['handleResult'];
4822
- declare const parseResult: (q: Query, parsers: ColumnsParsers | undefined, returnType: QueryReturnType | undefined, result: QueryResult, isSubQuery?: boolean) => unknown;
4823
- declare const parseRecord: (parsers: ColumnsParsers, row: any) => any;
4824
-
4825
4766
  interface SelectSelf {
4826
4767
  shape: QueryColumns;
4827
4768
  relations: RelationsBase;
@@ -4869,12 +4810,20 @@ type SelectResultColumnsAndObj<T extends SelectSelf, Columns extends PropertyKey
4869
4810
  } & (T['meta']['hasSelect'] extends true ? Omit<T['result'], Columns[number]> : unknown)>> : T[K];
4870
4811
  } & QueryMetaHasSelect;
4871
4812
  type SelectAsSelectable<Arg> = {
4872
- [K in keyof Arg]: Arg[keyof Arg] extends (q: never) => {
4813
+ [K in keyof Arg]: Arg[K] extends (q: never) => {
4814
+ returnType: 'value' | 'valueOrThrow';
4815
+ result: QueryColumns;
4816
+ } ? {
4817
+ [P in K]: {
4818
+ as: K;
4819
+ column: ReturnType<Arg[K]>['result']['value'];
4820
+ };
4821
+ } : Arg[K] extends (q: never) => {
4873
4822
  result: QueryColumns;
4874
4823
  } ? {
4875
- [C in keyof ReturnType<Arg[keyof Arg]>['result'] & string as `${K & string}.${C}`]: {
4824
+ [C in keyof ReturnType<Arg[K]>['result'] & string as `${K & string}.${C}`]: {
4876
4825
  as: C;
4877
- column: ReturnType<Arg[keyof Arg]>['result'][C];
4826
+ column: ReturnType<Arg[K]>['result'][C];
4878
4827
  };
4879
4828
  } : never;
4880
4829
  }[keyof Arg];
@@ -4912,14 +4861,19 @@ declare class Select {
4912
4861
  * subQueryResult: Otherdb.table.select('column').take(),
4913
4862
  * });
4914
4863
  *
4915
- * // select raw SQL value, the first argument of `raw` is a column type, it is used for return type of the query
4864
+ * // select raw SQL value, specify the returning type via <generic> syntax:
4865
+ * db.table.select({
4866
+ * raw: sql<number>`1 + 2`,
4867
+ * });
4868
+ *
4869
+ * // select raw SQL value, the resulting type can be set by providing a column type in such way:
4916
4870
  * db.table.select({
4917
- * raw: db.table.sql((t) => t.integer())`1 + 2`,
4871
+ * raw: sql`1 + 2`.type((t) => t.integer()),
4918
4872
  * });
4919
4873
  *
4920
4874
  * // same raw SQL query as above, but raw value is returned from a callback
4921
4875
  * db.table.select({
4922
- * raw: (q) => q.sql((t) => t.integer())`1 + 2`,
4876
+ * raw: (q) => q.sql`1 + 2`.type((t) => t.integer()),
4923
4877
  * });
4924
4878
  * ```
4925
4879
  *
@@ -5008,7 +4962,7 @@ declare class With {
5008
4962
  * id: columnTypes.integer(),
5009
4963
  * name: columnTypes.text(3, 100),
5010
4964
  * },
5011
- * db.table.sql`SELECT id, name FROM "someTable"`,
4965
+ * sql`SELECT id, name FROM "someTable"`,
5012
4966
  * );
5013
4967
  *
5014
4968
  * // accepts query:
@@ -5016,7 +4970,7 @@ declare class With {
5016
4970
  *
5017
4971
  * // accepts a callback for a query builder:
5018
4972
  * db.table.with('alias', (qb) =>
5019
- * qb.select({ one: db.table.sql`1`.type((t) => t.integer()) }),
4973
+ * qb.select({ one: sql`1`.type((t) => t.integer()) }),
5020
4974
  * );
5021
4975
  *
5022
4976
  * // All mentioned forms can accept options as a second argument:
@@ -5062,7 +5016,7 @@ declare class Union {
5062
5016
  * SomeTable.select('id', 'name').union(
5063
5017
  * [
5064
5018
  * OtherTable.select('id', 'name'),
5065
- * SomeTable.sql`SELECT id, name FROM "thirdTable"`,
5019
+ * sql`SELECT id, name FROM "thirdTable"`,
5066
5020
  * ],
5067
5021
  * true, // optional wrap parameter
5068
5022
  * );
@@ -5203,7 +5157,7 @@ declare class Update {
5203
5157
  * column1: 123,
5204
5158
  *
5205
5159
  * // use raw SQL to update the column
5206
- * column2: db.table.sql`2 + 2`,
5160
+ * column2: sql`2 + 2`,
5207
5161
  *
5208
5162
  * // use query that returns a single value
5209
5163
  * // returning multiple values will result in Postgres error
@@ -5326,7 +5280,7 @@ declare class Update {
5326
5280
  * const updatedCount = await db.table.find(1).updateRaw`name = ${value}`;
5327
5281
  *
5328
5282
  * // or update with `sql` function:
5329
- * await db.table.find(1).updateRaw(db.table.sql`name = ${value}`);
5283
+ * await db.table.find(1).updateRaw(sql`name = ${value}`);
5330
5284
  * ```
5331
5285
  * @param args - raw SQL via a template string or by using a `sql` method
5332
5286
  */
@@ -5899,17 +5853,17 @@ declare class QueryUpsertOrCreate {
5899
5853
  orCreate<T extends UpsertThis, BT extends CreateBelongsToData<T>>(this: T, data: OrCreateArg<T, BT>): UpsertResult<T>;
5900
5854
  }
5901
5855
 
5902
- declare abstract class RawSqlMethods<ColumnTypes> {
5856
+ declare class SqlMethod<ColumnTypes> {
5903
5857
  /**
5904
- * When there is a need to use a piece of raw SQL, use the `sql` method from tables, or a `raw` function imported from `orchid-orm`.
5858
+ * 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.
5905
5859
  *
5906
- * When selecting a raw SQL, specify a resulting type with `<generic>` syntax:
5860
+ * When selecting a custom SQL, specify a resulting type with `<generic>` syntax:
5907
5861
  *
5908
5862
  * ```ts
5863
+ * import { sql } from './baseTable';
5864
+ *
5909
5865
  * const result: { num: number }[] = await db.table.select({
5910
- * num: db.table.sql<number>`
5911
- * random() * 100
5912
- * `,
5866
+ * num: sql<number>`random() * 100`,
5913
5867
  * });
5914
5868
  * ```
5915
5869
  *
@@ -5918,20 +5872,10 @@ declare abstract class RawSqlMethods<ColumnTypes> {
5918
5872
  * This example assumes that the `timestamp` column was overridden with `asDate` as shown in [Override column types](/guide/columns-overview#override-column-types).
5919
5873
  *
5920
5874
  * ```ts
5921
- * const result: { timestamp: Date }[] = await db.table.select({
5922
- * timestamp: db.table.sql`now()`.type((t) => t.timestamp()),
5923
- * });
5924
- * ```
5925
- *
5926
- * Instead of `sql` method, you can use `raw` function from `orchid-orm` (or `pqb`) to do the same.
5927
- * The only difference, `raw` function don't have access to the overridden column types.
5928
- *
5929
- * ```ts
5930
- * import { raw } from 'orchid-orm';
5875
+ * import { sql } from './baseTable';
5931
5876
  *
5932
5877
  * const result: { timestamp: Date }[] = await db.table.select({
5933
- * // if you have overridden timestamp with `asDate` or `asNumber` it won't be parsed properly:
5934
- * timestamp: raw`now()`.type((t) => t.timestamp()),
5878
+ * timestamp: sql`now()`.type((t) => t.timestamp()),
5935
5879
  * });
5936
5880
  * ```
5937
5881
  *
@@ -5947,11 +5891,11 @@ declare abstract class RawSqlMethods<ColumnTypes> {
5947
5891
  * const result = await db.$from(subQuery).where({ sum: { gte: 5 } });
5948
5892
  * ```
5949
5893
  *
5950
- * `where` and other methods don't need the return type, so it can be omitted.
5951
- * You can pass SQL template directly to the `where`:
5894
+ * Many query methods have a version suffixed with `Sql`, you can pass an SQL template literal directly to these methods.
5895
+ * These methods are: `whereSql`, `whereNotSql`, `orderSql`, `havingSql`, `fromSql`, `findBySql`.
5952
5896
  *
5953
5897
  * ```ts
5954
- * await db.table.where`"someValue" = random() * 100`;
5898
+ * await db.table.whereSql`"someValue" = random() * 100`;
5955
5899
  * ```
5956
5900
  *
5957
5901
  * Interpolating values in template literals is completely safe:
@@ -5961,48 +5905,48 @@ declare abstract class RawSqlMethods<ColumnTypes> {
5961
5905
  * const { value } = req.params;
5962
5906
  *
5963
5907
  * // SQL injection is prevented by a library, this is safe:
5964
- * await db.table.where`column = ${value}`;
5908
+ * await db.table.whereSql`column = ${value}`;
5965
5909
  * ```
5966
5910
  *
5967
5911
  * 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.
5968
- * Instead, use the `column` method to reference a column:
5912
+ * Instead, use the [column](/guide/sql-expressions#column) or [ref](/guide/sql-expressions#ref) to reference a column:
5969
5913
  *
5970
5914
  * ```ts
5971
- * import { raw } from 'orchid-orm';
5972
- *
5973
5915
  * // ids will be prefixed with proper table names, no ambiguity:
5974
5916
  * db.table.join(db.otherTable, 'id', 'otherId').where`
5975
5917
  * ${db.table.column('id')} = 1 AND
5976
- * ${db.otherTable.column('id')} = 2
5918
+ * ${db.otherTable.ref('id')} = 2
5977
5919
  * `;
5978
5920
  * ```
5979
5921
  *
5980
5922
  * SQL can be passed with a simple string, it's important to note that this is not safe to interpolate values in it.
5981
5923
  *
5982
5924
  * ```ts
5983
- * import { raw } from 'orchid-orm';
5925
+ * import { sql } from './baseTable';
5984
5926
  *
5985
5927
  * // no interpolation is okay
5986
- * await db.table.where(raw({ raw: 'column = random() * 100' }));
5928
+ * await db.table.where(sql({ raw: 'column = random() * 100' }));
5987
5929
  *
5988
5930
  * // get value from user-provided params
5989
5931
  * const { value } = req.params;
5990
5932
  *
5991
5933
  * // this is NOT safe, SQL injection is possible:
5992
- * await db.table.where(raw({ raw: `column = random() * ${value}` }));
5934
+ * await db.table.where(sql({ raw: `column = random() * ${value}` }));
5993
5935
  * ```
5994
5936
  *
5995
- * To inject values into `raw` SQL strings, denote it with `$` in the string and provide `values` object.
5937
+ * To inject values into `sql({ raw: '...' })` SQL strings, denote it with `$` in the string and provide `values` object.
5996
5938
  *
5997
- * Use `$$` to provide column or/and table name (`column` method is more preferable). Column names will be quoted so don't quote them manually.
5939
+ * Use `$$` to provide column or/and table name (`column` or `ref` are preferable). Column names will be quoted so don't quote them manually.
5998
5940
  *
5999
5941
  * ```ts
5942
+ * import { sql } from './baseTable';
5943
+ *
6000
5944
  * // get value from user-provided params
6001
5945
  * const { value } = req.params;
6002
5946
  *
6003
5947
  * // this is SAFE, SQL injection are prevented:
6004
5948
  * await db.table.where(
6005
- * db.table.sql({
5949
+ * sql<boolean>({
6006
5950
  * raw: '$$column = random() * $value',
6007
5951
  * values: {
6008
5952
  * column: 'someTable.someColumn', // or simply 'column'
@@ -6016,45 +5960,41 @@ declare abstract class RawSqlMethods<ColumnTypes> {
6016
5960
  * Summarizing:
6017
5961
  *
6018
5962
  * ```ts
5963
+ * import { sql } from './baseTable';
5964
+ *
6019
5965
  * // simplest form:
6020
- * db.table.sql`key = ${value}`;
5966
+ * sql`key = ${value}`;
6021
5967
  *
6022
5968
  * // with resulting type:
6023
- * db.table.sql<boolean>`key = ${value}`;
5969
+ * sql<boolean>`key = ${value}`;
6024
5970
  *
6025
5971
  * // with column type for select:
6026
- * db.table.sql`key = ${value}`.type((t) => t.boolean());
5972
+ * sql`key = ${value}`.type((t) => t.boolean());
6027
5973
  *
6028
5974
  * // with column name via `column` method:
6029
- * db.table.sql`${db.table.column('column')} = ${value}`;
5975
+ * sql`${db.table.column('column')} = ${value}`;
6030
5976
  *
6031
5977
  * // raw SQL string, not allowed to interpolate values:
6032
- * db.table.sql({ raw: 'random()' });
5978
+ * sql({ raw: 'random()' });
6033
5979
  *
6034
5980
  * // with resulting type and `raw` string:
6035
- * db.table.sql<number>({ raw: 'random()' });
5981
+ * sql<number>({ raw: 'random()' });
6036
5982
  *
6037
5983
  * // with column name and a value in a `raw` string:
6038
- * db.table.sql({
5984
+ * sql({
6039
5985
  * raw: `$$column = $value`,
6040
5986
  * values: { column: 'columnName', value: 123 },
6041
5987
  * });
6042
5988
  *
6043
5989
  * // combine template literal, column type, and values:
6044
- * db.table.sql`($one + $two) / $one`
6045
- * .type((t) => t.numeric())
6046
- * .values({ one: 1, two: 2 });
5990
+ * sql`($one + $two) / $one`.type((t) => t.numeric()).values({ one: 1, two: 2 });
6047
5991
  * ```
6048
5992
  *
6049
5993
  * @param args - template literal or an object { raw: string }
6050
5994
  * @return object that has `type` and `values` methods
6051
5995
  */
6052
- sql<T = unknown>(this: {
6053
- columnTypes: ColumnTypes;
6054
- }, ...args: StaticSQLArgs): RawSQL<QueryColumn<T>, ColumnTypes>;
6055
- sql<T = unknown>(this: {
6056
- columnTypes: ColumnTypes;
6057
- }, ...args: [DynamicSQLArg]): DynamicRawSQL<QueryColumn<T>, ColumnTypes>;
5996
+ sql<T = unknown>(this: PickQueryColumnTypes, ...args: StaticSQLArgs): RawSQL<QueryColumn<T>, ColumnTypes>;
5997
+ sql<T = unknown>(this: PickQueryColumnTypes, ...args: [DynamicSQLArg]): DynamicRawSQL<QueryColumn<T>, ColumnTypes>;
6058
5998
  }
6059
5999
 
6060
6000
  type QueryTransformFn<T extends Query> = (input: T['then'] extends QueryThen<infer Data> ? Data : never) => unknown;
@@ -6118,6 +6058,121 @@ declare class TransformMethods {
6118
6058
  transform<T extends Query, Fn extends QueryTransformFn<T>>(this: T, fn: Fn): QueryTransform<T, ReturnType<Fn>>;
6119
6059
  }
6120
6060
 
6061
+ declare class ColumnRefExpression<T extends QueryColumn> extends Expression<T> {
6062
+ name: string;
6063
+ result: {
6064
+ value: T;
6065
+ };
6066
+ q: ExpressionData;
6067
+ constructor(value: T, name: string);
6068
+ makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
6069
+ }
6070
+ declare class RefExpression<T extends QueryColumn> extends Expression<T> {
6071
+ q: QueryData;
6072
+ ref: string;
6073
+ result: {
6074
+ value: T;
6075
+ };
6076
+ constructor(value: T, q: QueryData, ref: string);
6077
+ makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
6078
+ }
6079
+ interface QueryReturnsFnAdd<T extends PickQueryColumnTypes> extends QueryMetaHasSelect {
6080
+ type<C extends QueryColumn>(fn: (types: T['columnTypes']) => C): {
6081
+ [K in keyof T]: K extends 'result' ? {
6082
+ value: C;
6083
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<C['outputType']> : T[K];
6084
+ } & C['operators'];
6085
+ }
6086
+ type SetQueryReturnsFn<T extends PickQueryColumnTypes, C extends PickOutputType> = {
6087
+ [K in keyof T]: K extends 'result' ? {
6088
+ value: C;
6089
+ } : K extends 'returnType' ? 'valueOrThrow' : K extends 'then' ? QueryThen<C['outputType']> : T[K];
6090
+ } & QueryReturnsFnAdd<T>;
6091
+ declare class ExpressionMethods {
6092
+ /**
6093
+ * `column` references a table column, this can be used in raw SQL or when building a column expression.
6094
+ * Only for referencing a column in the query's table. For referencing joined table's columns, see [ref](#ref).
6095
+ *
6096
+ * ```ts
6097
+ * await db.table.select({
6098
+ * // select `("table"."id" = 1 OR "table"."name" = 'name') AS "one"`,
6099
+ * // returns a boolean
6100
+ * one: (q) =>
6101
+ * q.sql<boolean>`${q.column('id')} = ${1} OR ${q.column('name')} = ${'name'}`,
6102
+ *
6103
+ * // selects the same as above, but by building a query
6104
+ * two: (q) => q.column('id').equals(1).or(q.column('name').equals('name')),
6105
+ * });
6106
+ * ```
6107
+ *
6108
+ * @param name - column name
6109
+ */
6110
+ column<T extends PickQueryShape, K extends keyof T['shape']>(this: T, name: K): ColumnRefExpression<T['shape'][K]> & T['shape'][K]['operators'];
6111
+ /**
6112
+ * `ref` is similar to [column](#column), but it also allows to reference a column of joined table,
6113
+ * and other dynamically defined columns.
6114
+ *
6115
+ * ```ts
6116
+ * await db.table.join('otherTable').select({
6117
+ * // select `("otherTable"."id" = 1 OR "otherTable"."name" = 'name') AS "one"`,
6118
+ * // returns a boolean
6119
+ * one: (q) =>
6120
+ * q.sql<boolean>`${q.ref('otherTable.id')} = ${1} OR ${q.ref(
6121
+ * 'otherTable.name',
6122
+ * )} = ${'name'}`,
6123
+ *
6124
+ * // selects the same as above, but by building a query
6125
+ * two: (q) =>
6126
+ * q
6127
+ * .ref('otherTable.id')
6128
+ * .equals(1)
6129
+ * .or(q.ref('otherTable.name').equals('name')),
6130
+ * });
6131
+ * ```
6132
+ *
6133
+ * @param arg - any available column name, such as of a joined table
6134
+ */
6135
+ ref<T extends PickQueryMeta, K extends keyof T['meta']['selectable'] & string>(this: T, arg: K): RefExpression<T['meta']['selectable'][K]['column']> & T['meta']['selectable'][K]['column']['operators'];
6136
+ val(value: unknown): ValExpression;
6137
+ /**
6138
+ * `fn` allows to call an arbitrary SQL function.
6139
+ *
6140
+ * For example, calling `sqrt` function to get a square root from some numeric column:
6141
+ *
6142
+ * ```ts
6143
+ * const q = await User.select({
6144
+ * sqrt: (q) => q.fn<number>('sqrt', ['numericColumn']),
6145
+ * }).take();
6146
+ *
6147
+ * q.sqrt; // has type `number` just as provided
6148
+ * ```
6149
+ *
6150
+ * If this is an aggregate function, you can specify aggregation options (see [Aggregate](/guide/aggregate.html)) via third parameter.
6151
+ *
6152
+ * Use `type` method to specify a column type so that its operators such as `lt` and `gt` become available:
6153
+ *
6154
+ * ```ts
6155
+ * const q = await User.select({
6156
+ * // Produces `sqrt("numericColumn") > 5`
6157
+ * sqrtIsGreaterThan5: (q) =>
6158
+ * q
6159
+ * .fn('sqrt', ['numericColumn'])
6160
+ * .type((t) => t.float())
6161
+ * .gt(5),
6162
+ * }).take();
6163
+ *
6164
+ * // Return type is boolean | null
6165
+ * // todo: it should be just boolean if the column is not nullable, but for now it's always nullable
6166
+ * q.sqrtIsGreaterThan5;
6167
+ * ```
6168
+ *
6169
+ * @param fn
6170
+ * @param args
6171
+ * @param options
6172
+ */
6173
+ fn<T extends PickQueryMetaResultRelationsWindowsColumnTypes, Type = unknown, C extends QueryColumn = QueryColumn<Type>>(this: T, fn: string, args: SelectableOrExpression<T>[], options?: AggregateOptions<T>): SetQueryReturnsFn<T, C>;
6174
+ }
6175
+
6121
6176
  interface WindowArg<T extends OrderArgSelf> {
6122
6177
  [K: string]: WindowArgDeclaration<T> | Expression;
6123
6178
  }
@@ -6156,24 +6211,11 @@ type QueryHelper<T extends PickQueryMetaShape, Args extends unknown[], Result> =
6156
6211
  result: Result;
6157
6212
  };
6158
6213
  type QueryHelperResult<T extends QueryHelper<Query, unknown[], unknown>> = T['result'];
6159
- declare class ColumnRefExpression<T extends QueryColumn> extends Expression<T> {
6160
- name: string;
6161
- result: {
6162
- value: T;
6163
- };
6164
- q: ExpressionData;
6165
- constructor(value: T, name: string);
6166
- makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
6167
- }
6168
- declare class RefExpression<T extends QueryColumn> extends Expression<T> {
6169
- q: QueryData;
6170
- ref: string;
6171
- result: {
6172
- value: T;
6173
- };
6174
- constructor(value: T, q: QueryData, ref: string);
6175
- makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
6176
- }
6214
+ type NarrowTypeResult<T extends PickQueryMetaResultReturnType, Narrow> = {
6215
+ [K in keyof T['result']]: K extends keyof Narrow ? {
6216
+ [P in keyof T['result'][K]]: P extends 'outputType' ? Narrow[K] extends T['result'][K]['outputType'] ? Narrow[K] : `narrowType() error: passed type does not exist in '${K & string}'s type union` : T['result'][K][P];
6217
+ } : T['result'][K];
6218
+ };
6177
6219
  type WrapQueryArg = FromQuerySelf;
6178
6220
  declare const _queryAll: <T extends Query>(q: T) => SetQueryReturnsAll<T>;
6179
6221
  declare const _queryTake: <T extends PickQueryResult>(q: T) => SetQueryReturnsOne<T>;
@@ -6182,7 +6224,7 @@ declare const _queryExec: <T extends Query>(q: T) => never;
6182
6224
  declare const _queryFindBy: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOne<WhereResult<T>>;
6183
6225
  declare const _queryFindByOptional: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOneOptional<WhereResult<T>>;
6184
6226
  declare const _queryRows: <T extends Query>(q: T) => SetQueryReturnsRows<T>;
6185
- interface QueryMethods<ColumnTypes> extends AsMethods, AggregateMethods, Select, From, Join, With, Union, JsonModifiers, JsonMethods, Create, Update, Delete, Transaction, For, Where, SearchMethods, Clear, Having, Then, QueryLog, QueryHooks, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, RawSqlMethods<ColumnTypes>, TransformMethods, ScopeMethods, SoftDeleteMethods {
6227
+ 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 {
6186
6228
  }
6187
6229
  declare class QueryMethods<ColumnTypes> {
6188
6230
  /**
@@ -6283,11 +6325,13 @@ declare class QueryMethods<ColumnTypes> {
6283
6325
  * db.table.distinct().select('name');
6284
6326
  * ```
6285
6327
  *
6286
- * Can accept column names or raw expressions to place it to `DISTINCT ON (...)`:
6328
+ * Can accept column names or raw SQL expressions to place it to `DISTINCT ON (...)`:
6287
6329
  *
6288
6330
  * ```ts
6331
+ * import { sql } from './baseTable';
6332
+ *
6289
6333
  * // Distinct on the name and raw SQL
6290
- * db.table.distinct('name', db.table.sql`raw sql`).select('id', 'name');
6334
+ * db.table.distinct('name', sql`raw sql`).select('id', 'name');
6291
6335
  * ```
6292
6336
  *
6293
6337
  * @param columns - column names or a raw SQL
@@ -6405,9 +6449,11 @@ declare class QueryMethods<ColumnTypes> {
6405
6449
  * Also, it's possible to group by a selected value:
6406
6450
  *
6407
6451
  * ```ts
6452
+ * import { sql } from './baseTable';
6453
+ *
6408
6454
  * const results = db.product
6409
6455
  * .select({
6410
- * month: db.product.sql`extract(month from "createdAt")`.type((t) =>
6456
+ * month: sql`extract(month from "createdAt")`.type((t) =>
6411
6457
  * // month is returned as string, parse it to int
6412
6458
  * t.string().parse(parseInt),
6413
6459
  * ),
@@ -6491,8 +6537,6 @@ declare class QueryMethods<ColumnTypes> {
6491
6537
  *
6492
6538
  * ```ts
6493
6539
  * db.table.orderSql`raw sql`;
6494
- * // or
6495
- * db.table.orderSql(db.table.sql`raw sql`);
6496
6540
  * ```
6497
6541
  *
6498
6542
  * @param args - SQL expression
@@ -6655,50 +6699,44 @@ declare class QueryMethods<ColumnTypes> {
6655
6699
  */
6656
6700
  makeHelper<T extends PickQueryMetaShape, Args extends unknown[], Result>(this: T, fn: (q: T, ...args: Args) => Result): QueryHelper<T, Args, Result>;
6657
6701
  /**
6658
- * `column` references a table column, this can be used in raw SQL or when building a column expression.
6659
- * Only for referencing a column in the query's table. For referencing joined table's columns, see [ref](#ref).
6702
+ * Narrows a part of the query output type.
6703
+ * Use with caution, type-safety isn't guaranteed with it.
6704
+ * This is similar so using `as` keyword from TypeScript, except that it applies only to a part of the result.
6660
6705
  *
6661
- * ```ts
6662
- * await db.table.select({
6663
- * // select `("table"."id" = 1 OR "table"."name" = 'name') AS "one"`,
6664
- * // returns a boolean
6665
- * one: (q) =>
6666
- * q.sql<boolean>`${q.column('id')} = ${1} OR ${q.column('name')} = ${'name'}`,
6667
- *
6668
- * // selects the same as above, but by building a query
6669
- * two: (q) => q.column('id').equals(1).or(q.column('name').equals('name')),
6670
- * });
6671
- * ```
6672
- *
6673
- * @param name - column name
6674
- */
6675
- column<T extends PickQueryShape, K extends keyof T['shape']>(this: T, name: K): ColumnRefExpression<T['shape'][K]> & T['shape'][K]['operators'];
6676
- /**
6677
- * `ref` is similar to [column](#column), but it also allows to reference a column of joined table,
6678
- * and other dynamically defined columns.
6706
+ * The syntax `()<{ ... }>()` is enforced by internal limitations.
6679
6707
  *
6680
6708
  * ```ts
6681
- * await db.table.join('otherTable').select({
6682
- * // select `("otherTable"."id" = 1 OR "otherTable"."name" = 'name') AS "one"`,
6683
- * // returns a boolean
6684
- * one: (q) =>
6685
- * q.sql<boolean>`${q.ref('otherTable.id')} = ${1} OR ${q.ref(
6686
- * 'otherTable.name',
6687
- * )} = ${'name'}`,
6709
+ * const rows = db.table
6710
+ * // filter out records where the `nullableColumn` is null
6711
+ * .where({ nullableColumn: { not: null } });
6712
+ * // narrows only a specified column, the rest of result is unchanged
6713
+ * .narrowType()<{ nullableColumn: string }>()
6688
6714
  *
6689
- * // selects the same as above, but by building a query
6690
- * two: (q) =>
6691
- * q
6692
- * .ref('otherTable.id')
6693
- * .equals(1)
6694
- * .or(q.ref('otherTable.name').equals('name')),
6695
- * });
6696
- * ```
6715
+ * // the column had type `string | null`, now it is `string`
6716
+ * rows[0].nullableColumn
6697
6717
  *
6698
- * @param arg - any available column name, such as of a joined table
6718
+ * // imagine that table has a enum column kind with variants 'first' | 'second'
6719
+ * // and a boolean `approved`
6720
+ * db.table
6721
+ * .where({ kind: 'first', approved: true })
6722
+ * // after applying such `where`, it's safe to narrow the type to receive the literal values
6723
+ * .narrowType()<{ kind: 'first', approved: true }>();
6724
+ * ```
6699
6725
  */
6700
- ref<T extends PickQueryMeta, K extends keyof T['meta']['selectable'] & string>(this: T, arg: K): RefExpression<T['meta']['selectable'][K]['column']> & T['meta']['selectable'][K]['column']['operators'];
6726
+ narrowType<T extends PickQueryMetaResultReturnType>(this: T): <Narrow>() => {
6727
+ [K in keyof T]: K extends 'result' ? NarrowTypeResult<T, Narrow> : K extends 'then' ? QueryThen<GetQueryResult<T, NarrowTypeResult<T, Narrow>>> : T[K];
6728
+ };
6729
+ }
6730
+
6731
+ declare const queryMethodByReturnType: {
6732
+ [K in QueryReturnType]: 'query' | 'arrays';
6733
+ };
6734
+ declare class Then {
6735
+ catch(this: Query, fn: (reason: any) => unknown): Promise<unknown>;
6701
6736
  }
6737
+ declare const handleResult: CommonQueryData['handleResult'];
6738
+ declare const parseResult: (q: Query, parsers: ColumnsParsers | undefined, returnType: QueryReturnType | undefined, result: QueryResult, isSubQuery?: boolean) => unknown;
6739
+ declare const parseRecord: (parsers: ColumnsParsers, row: any) => any;
6702
6740
 
6703
6741
  declare function queryJson<T>(self: T, coalesce?: boolean): SetQueryReturnsColumnOptional<T, QueryColumn<string>>;
6704
6742
 
@@ -6786,9 +6824,11 @@ interface PickQueryMetaResultRelations extends PickQueryResult, PickQueryMeta, P
6786
6824
  }
6787
6825
  interface PickQueryMetaResultRelationsWindows extends PickQueryMetaResultRelations, PickQueryWindows {
6788
6826
  }
6789
- interface PickQueryMetaResultRelationsWindowsColumnTypes extends PickQueryMetaResultRelationsWindows {
6827
+ interface PickQueryColumnTypes {
6790
6828
  columnTypes: unknown;
6791
6829
  }
6830
+ interface PickQueryMetaResultRelationsWindowsColumnTypes extends PickQueryMetaResultRelationsWindows, PickQueryColumnTypes {
6831
+ }
6792
6832
  interface PickQueryMetaTable extends PickQueryMeta, PickQueryTable {
6793
6833
  }
6794
6834
  interface PickQueryMetaTableShape extends PickQueryMetaTable, PickQueryShape {
@@ -6842,8 +6882,8 @@ declare const queryTypeWithLimitOne: {
6842
6882
  void: true | undefined;
6843
6883
  };
6844
6884
  declare const isQueryReturnsAll: (q: Query) => boolean;
6845
- type QueryReturnsAll<T extends QueryReturnType> = (QueryReturnType extends T ? 'all' : T) extends 'all' ? true : false;
6846
- type GetQueryResult<T extends PickQueryReturnType, Result extends QueryColumns> = QueryReturnsAll<T['returnType']> extends true ? ColumnShapeOutput<Result>[] : T['returnType'] extends 'one' ? ColumnShapeOutput<Result> | undefined : T['returnType'] extends 'oneOrThrow' ? ColumnShapeOutput<Result> : T['returnType'] extends 'value' ? Result['value']['outputType'] | undefined : T['returnType'] extends 'valueOrThrow' ? Result['value']['outputType'] : T['returnType'] extends 'rows' ? ColumnShapeOutput<Result>[keyof Result][][] : T['returnType'] extends 'pluck' ? Result['pluck']['outputType'][] : T['returnType'] extends 'rowCount' ? number : T['returnType'] extends 'void' ? void : never;
6885
+ type QueryReturnsAll<T extends QueryReturnType> = QueryReturnType extends T ? true : T extends 'all' ? true : false;
6886
+ type GetQueryResult<T extends PickQueryReturnType, Result extends QueryColumns> = QueryReturnsAll<T['returnType']> extends true ? ColumnShapeOutput<Result>[] : T['returnType'] extends 'one' ? ColumnShapeOutput<Result> | undefined : T['returnType'] extends 'oneOrThrow' ? ColumnShapeOutput<Result> : T['returnType'] extends 'value' ? Result['value']['outputType'] | undefined : T['returnType'] extends 'valueOrThrow' ? Result['value']['outputType'] : T['returnType'] extends 'rows' ? ColumnShapeOutput<Result>[keyof Result][][] : T['returnType'] extends 'pluck' ? Result['pluck']['outputType'][] : T['returnType'] extends 'rowCount' ? number : void;
6847
6887
  type AddQuerySelect<T extends PickQueryMetaResultReturnType, Result extends QueryColumns> = {
6848
6888
  [K in keyof T]: K extends 'result' ? {
6849
6889
  [K in (T['meta']['hasSelect'] extends true ? keyof T['result'] : never) | keyof Result]: K extends keyof Result ? Result[K] : K extends keyof T['result'] ? T['result'][K] : never;
@@ -7633,4 +7673,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
7633
7673
  */
7634
7674
  declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
7635
7675
 
7636
- 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, 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, OrchidOrmError, OrchidOrmInternalError, OrderArg, OrderArgSelf, OrderArgs, OrderItem, OrderTsQueryConfig, Over, PathColumn, PickColumnData, PickQueryBaseQuery, 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, QueryResult, QueryReturnsAll, QueryScopeData, QueryScopes, QuerySourceItem, QueryTransform, QueryTransformFn, QueryUpsertOrCreate, QueryWithComputed, QueryWithTable, RawSQL, RawSqlMethods, 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, 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 };
7676
+ 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, 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, 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 };