pqb 0.30.2 → 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';
@@ -1054,7 +1054,8 @@ declare class Join {
1054
1054
  * ```ts
1055
1055
  * db.user.join(
1056
1056
  * db.message,
1057
- * 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")`,
1058
1059
  * );
1059
1060
  * ```
1060
1061
  *
@@ -1063,16 +1064,16 @@ declare class Join {
1063
1064
  * ```ts
1064
1065
  * db.user.join(
1065
1066
  * db.message,
1066
- * db.user.sql`lower("message"."text")`,
1067
- * db.user.sql`lower("user"."name")`,
1067
+ * sql`lower("message"."text")`,
1068
+ * sql`lower("user"."name")`,
1068
1069
  * );
1069
1070
  *
1070
1071
  * // with operator:
1071
1072
  * db.user.join(
1072
1073
  * db.message,
1073
- * db.user.sql`lower("message"."text")`,
1074
+ * sql`lower("message"."text")`,
1074
1075
  * '!=',
1075
- * db.user.sql`lower("user"."name")`,
1076
+ * sql`lower("user"."name")`,
1076
1077
  * );
1077
1078
  * ```
1078
1079
  *
@@ -1086,7 +1087,7 @@ declare class Join {
1086
1087
  * 'message.userId': 'user.id',
1087
1088
  *
1088
1089
  * // value can be a raw SQL expression:
1089
- * text: db.user.sql`lower("user"."name")`,
1090
+ * text: sql`lower("user"."name")`,
1090
1091
  * });
1091
1092
  * ```
1092
1093
  *
@@ -1515,7 +1516,8 @@ declare class Where {
1515
1516
  * },
1516
1517
  *
1517
1518
  * // where column equals to raw SQL
1518
- * column: db.table.sql`sql expression`,
1519
+ * // import `sql` from your `BaseTable`
1520
+ * column: sql`sql expression`,
1519
1521
  * });
1520
1522
  * ```
1521
1523
  *
@@ -1564,12 +1566,7 @@ declare class Where {
1564
1566
  * `where` supports raw SQL:
1565
1567
  *
1566
1568
  * ```ts
1567
- * db.table.where(db.table.sql`a = b`);
1568
- *
1569
- * // or
1570
- * import { raw } from 'orchid-orm';
1571
- *
1572
- * db.table.where(raw`a = b`);
1569
+ * db.table.where(sql`a = b`);
1573
1570
  * ```
1574
1571
  *
1575
1572
  * `where` can accept a callback with a specific query builder containing all "where" methods such as `where`, `orWhere`, `whereNot`, `whereIn`, `whereExists`:
@@ -1590,7 +1587,7 @@ declare class Where {
1590
1587
  * db.table.where(
1591
1588
  * { id: 1 },
1592
1589
  * db.table.where({ name: 'John' }),
1593
- * db.table.sql`a = b`,
1590
+ * sql`a = b`,
1594
1591
  * );
1595
1592
  * ```
1596
1593
  *
@@ -1703,8 +1700,6 @@ declare class Where {
1703
1700
  * All column operators can take a value of the same type as the column, a sub-query, or a raw SQL expression:
1704
1701
  *
1705
1702
  * ```ts
1706
- * import { sql } from 'orchid-orm';
1707
- *
1708
1703
  * db.table.where({
1709
1704
  * numericColumn: {
1710
1705
  * // lower than 5
@@ -1753,7 +1748,7 @@ declare class Where {
1753
1748
  * // WHERE "column" IN (SELECT "column" FROM "otherTable")
1754
1749
  * in: OtherTable.select('column'),
1755
1750
  *
1756
- * in: db.table.sql`('a', 'b')`,
1751
+ * in: sql`('a', 'b')`,
1757
1752
  * },
1758
1753
  * });
1759
1754
  * ```
@@ -1800,7 +1795,7 @@ declare class Where {
1800
1795
  * between: [1, 10],
1801
1796
  *
1802
1797
  * // sub-query and raw SQL expression
1803
- * between: [OtherTable.select('column').take(), db.table.sql`2 + 2`],
1798
+ * between: [OtherTable.select('column').take(), sql`2 + 2`],
1804
1799
  * },
1805
1800
  * });
1806
1801
  * ```
@@ -1887,15 +1882,7 @@ declare class Where {
1887
1882
  * Use a custom SQL expression in `WHERE` statement:
1888
1883
  *
1889
1884
  * ```ts
1890
- * db.table.where`a = b`;
1891
- *
1892
- * // or
1893
- * db.table.where(db.table.sql`a = b`);
1894
- *
1895
- * // or
1896
- * import { raw } from 'orchid-orm';
1897
- *
1898
- * db.table.where(raw`a = b`);
1885
+ * db.table.whereSql`a = b`;
1899
1886
  * ```
1900
1887
  *
1901
1888
  * @param args - SQL expression
@@ -1918,10 +1905,10 @@ declare class Where {
1918
1905
  */
1919
1906
  whereNot<T extends PickQueryMetaRelations>(this: T, ...args: WhereNotArgs<T>): WhereResult<T>;
1920
1907
  /**
1921
- * `whereNot` version accepting SQL expression:
1908
+ * `whereNotSql` is a version of `whereNot` accepting SQL expression:
1922
1909
  *
1923
1910
  * ```ts
1924
- * db.table.whereNot`sql expression`
1911
+ * db.table.whereNotSql`sql expression`
1925
1912
  * ```
1926
1913
  *
1927
1914
  * @param args - SQL expression
@@ -1989,7 +1976,7 @@ declare class Where {
1989
1976
  * It supports raw SQL expression:
1990
1977
  *
1991
1978
  * ```ts
1992
- * db.table.whereIn(['id', 'name'], db.table.sql`((1, 'one'), (2, 'two'))`);
1979
+ * db.table.whereIn(['id', 'name'], sql`((1, 'one'), (2, 'two'))`);
1993
1980
  * ```
1994
1981
  */
1995
1982
  whereIn<T extends PickQueryMetaRelations, Column extends WhereInColumn<T>>(this: T, ...args: [column: Column, values: WhereInValues<T, Column>] | [arg: WhereInArg<T>]): WhereResult<T>;
@@ -3232,41 +3219,6 @@ type StringColumn = QueryColumn<string, OperatorsText>;
3232
3219
  type StringNullable = QueryColumn<string | null, OperatorsText>;
3233
3220
  type NullableStringReturn<T> = SetQueryReturnsColumnOrThrow<T, StringNullable> & OperatorsText;
3234
3221
  declare class AggregateMethods {
3235
- /**
3236
- * `fn` allows to call an arbitrary SQL function.
3237
- *
3238
- * For example, calling `sqrt` function to get a square root from some numeric column:
3239
- *
3240
- * ```ts
3241
- * const q = await User.select({
3242
- * // todo: use type callback instead of generic type
3243
- * sqrt: (q) => q.fn<number>('sqrt', ['numericColumn']),
3244
- * }).take();
3245
- *
3246
- * q.sqrt; // has type `number` just as provided
3247
- * ```
3248
- *
3249
- * If this is an aggregate function, you can specify aggregation options via third parameter.
3250
- *
3251
- * Forth parameter is for runtime column type. When specified, allows to chain the function with the column operators:
3252
- *
3253
- * ```ts
3254
- * const q = await User.select({
3255
- * // chain `sqrt("numericColumn")` with the "greater than 5"
3256
- * sqrtIsGreaterThan5: (q) => q.fn('sqrt', ['numericColumn'], {}, (t) => t.float()).gt(5),
3257
- * }).take();
3258
- *
3259
- * // Return type is boolean | null
3260
- * // todo: it should be just boolean if the column is not nullable, but for now it's always nullable
3261
- * q.sqrtIsGreaterThan5
3262
- * ```
3263
- *
3264
- * @param fn
3265
- * @param args
3266
- * @param options
3267
- * @param type
3268
- */
3269
- 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'];
3270
3222
  /**
3271
3223
  * Use `exists()` to check if there is at least one record-matching condition.
3272
3224
  *
@@ -3513,7 +3465,7 @@ declare class AggregateMethods {
3513
3465
  * // select a column with alias
3514
3466
  * nameAlias: 'name',
3515
3467
  * // select raw SQL with alias
3516
- * foo: db.table.sql<string>`"bar" || "baz"`,
3468
+ * foo: sql<string>`"bar" || "baz"`,
3517
3469
  * },
3518
3470
  * aggregateOptions,
3519
3471
  * );
@@ -3523,7 +3475,7 @@ declare class AggregateMethods {
3523
3475
  * object: (q) =>
3524
3476
  * q.jsonObjectAgg({
3525
3477
  * nameAlias: 'name',
3526
- * foo: db.table.sql<string>`"bar" || "baz"`,
3478
+ * foo: sql<string>`"bar" || "baz"`,
3527
3479
  * }),
3528
3480
  * });
3529
3481
  * ```
@@ -3822,7 +3774,7 @@ declare class Create {
3822
3774
  *
3823
3775
  * await db.table.create({
3824
3776
  * // raw SQL
3825
- * column1: db.table.sql`'John' | 'Doe'`,
3777
+ * column1: sql`'John' || ' ' || 'Doe'`,
3826
3778
  *
3827
3779
  * // query that returns a single value
3828
3780
  * // returning multiple values will result in Postgres error
@@ -3877,7 +3829,7 @@ declare class Create {
3877
3829
  * ```ts
3878
3830
  * const oneRecord = await db.table.createRaw({
3879
3831
  * columns: ['name', 'amount'],
3880
- * values: db.table.sql`'name', random()`,
3832
+ * values: sql`'name', random()`,
3881
3833
  * });
3882
3834
  * ```
3883
3835
  *
@@ -3902,7 +3854,7 @@ declare class Create {
3902
3854
  * ```ts
3903
3855
  * const manyRecords = await db.table.createManyRaw({
3904
3856
  * columns: ['name', 'amount'],
3905
- * values: [db.table.sql`'one', 2`, db.table.sql`'three', 4`],
3857
+ * values: [sql`'one', 2`, sql`'three', 4`],
3906
3858
  * });
3907
3859
  * ```
3908
3860
  *
@@ -4048,11 +4000,11 @@ declare class Create {
4048
4000
  * // raw SQL expression:
4049
4001
  * db.table
4050
4002
  * .create(data)
4051
- * .onConfict(db.table.sql`(email) where condition`)
4003
+ * .onConfict(sql`(email) where condition`)
4052
4004
  * .merge();
4053
4005
  * ```
4054
4006
  *
4055
- * You can use the db.table.sql function in onConflict.
4007
+ * You can use the `sql` function exported from your `BaseTable` file in onConflict.
4056
4008
  * It can be useful to specify a condition when you have a partial index:
4057
4009
  *
4058
4010
  * ```ts
@@ -4063,7 +4015,7 @@ declare class Create {
4063
4015
  * active: true,
4064
4016
  * })
4065
4017
  * // ignore only when having conflicting email and when active is true.
4066
- * .onConflict(db.table.sql`(email) where active`)
4018
+ * .onConflict(sql`(email) where active`)
4067
4019
  * .ignore();
4068
4020
  * ```
4069
4021
  *
@@ -4149,7 +4101,7 @@ declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflic
4149
4101
  * db.table
4150
4102
  * .create(data)
4151
4103
  * .onConflict()
4152
- * .set(db.table.sql`raw SQL expression`);
4104
+ * .set(sql`raw SQL expression`);
4153
4105
  *
4154
4106
  * // update records only on certain conditions
4155
4107
  * db.table
@@ -4344,7 +4296,6 @@ declare class From {
4344
4296
  * ```ts
4345
4297
  * const value = 123;
4346
4298
  * db.table.fromSql`value = ${value}`;
4347
- * db.table.fromSql(db.table.sql`value = ${value}`);
4348
4299
  * ```
4349
4300
  *
4350
4301
  * @param args - SQL expression
@@ -4369,16 +4320,20 @@ declare class From {
4369
4320
 
4370
4321
  declare class QueryGet {
4371
4322
  /**
4372
- * `.get` returns a single value, it will add `LIMIT 1` to the query, and accepts a column name or a raw expression.
4373
- * 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`.
4374
4326
  *
4375
4327
  * ```ts
4376
4328
  * import { NumberColumn } from 'orchid-orm';
4329
+ * import { sql } from './baseTable';
4377
4330
  *
4378
4331
  * const firstName: string = await db.table.get('name');
4379
4332
  *
4380
- * const rawResult: number = await db.table.get(
4381
- * 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',
4382
4337
  * );
4383
4338
  * ```
4384
4339
  *
@@ -4460,7 +4415,7 @@ declare class Having {
4460
4415
  * Provide SQL expression for the `HAVING` SQL statement:
4461
4416
  *
4462
4417
  * ```ts
4463
- * db.table.having`count(*) >= ${10}`;
4418
+ * db.table.havingSql`count(*) >= ${10}`;
4464
4419
  * ```
4465
4420
  *
4466
4421
  * @param args - SQL expression
@@ -4906,14 +4861,19 @@ declare class Select {
4906
4861
  * subQueryResult: Otherdb.table.select('column').take(),
4907
4862
  * });
4908
4863
  *
4909
- * // 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:
4910
4870
  * db.table.select({
4911
- * raw: db.table.sql((t) => t.integer())`1 + 2`,
4871
+ * raw: sql`1 + 2`.type((t) => t.integer()),
4912
4872
  * });
4913
4873
  *
4914
4874
  * // same raw SQL query as above, but raw value is returned from a callback
4915
4875
  * db.table.select({
4916
- * raw: (q) => q.sql((t) => t.integer())`1 + 2`,
4876
+ * raw: (q) => q.sql`1 + 2`.type((t) => t.integer()),
4917
4877
  * });
4918
4878
  * ```
4919
4879
  *
@@ -5002,7 +4962,7 @@ declare class With {
5002
4962
  * id: columnTypes.integer(),
5003
4963
  * name: columnTypes.text(3, 100),
5004
4964
  * },
5005
- * db.table.sql`SELECT id, name FROM "someTable"`,
4965
+ * sql`SELECT id, name FROM "someTable"`,
5006
4966
  * );
5007
4967
  *
5008
4968
  * // accepts query:
@@ -5010,7 +4970,7 @@ declare class With {
5010
4970
  *
5011
4971
  * // accepts a callback for a query builder:
5012
4972
  * db.table.with('alias', (qb) =>
5013
- * qb.select({ one: db.table.sql`1`.type((t) => t.integer()) }),
4973
+ * qb.select({ one: sql`1`.type((t) => t.integer()) }),
5014
4974
  * );
5015
4975
  *
5016
4976
  * // All mentioned forms can accept options as a second argument:
@@ -5056,7 +5016,7 @@ declare class Union {
5056
5016
  * SomeTable.select('id', 'name').union(
5057
5017
  * [
5058
5018
  * OtherTable.select('id', 'name'),
5059
- * SomeTable.sql`SELECT id, name FROM "thirdTable"`,
5019
+ * sql`SELECT id, name FROM "thirdTable"`,
5060
5020
  * ],
5061
5021
  * true, // optional wrap parameter
5062
5022
  * );
@@ -5197,7 +5157,7 @@ declare class Update {
5197
5157
  * column1: 123,
5198
5158
  *
5199
5159
  * // use raw SQL to update the column
5200
- * column2: db.table.sql`2 + 2`,
5160
+ * column2: sql`2 + 2`,
5201
5161
  *
5202
5162
  * // use query that returns a single value
5203
5163
  * // returning multiple values will result in Postgres error
@@ -5320,7 +5280,7 @@ declare class Update {
5320
5280
  * const updatedCount = await db.table.find(1).updateRaw`name = ${value}`;
5321
5281
  *
5322
5282
  * // or update with `sql` function:
5323
- * await db.table.find(1).updateRaw(db.table.sql`name = ${value}`);
5283
+ * await db.table.find(1).updateRaw(sql`name = ${value}`);
5324
5284
  * ```
5325
5285
  * @param args - raw SQL via a template string or by using a `sql` method
5326
5286
  */
@@ -5893,17 +5853,17 @@ declare class QueryUpsertOrCreate {
5893
5853
  orCreate<T extends UpsertThis, BT extends CreateBelongsToData<T>>(this: T, data: OrCreateArg<T, BT>): UpsertResult<T>;
5894
5854
  }
5895
5855
 
5896
- declare abstract class RawSqlMethods<ColumnTypes> {
5856
+ declare class SqlMethod<ColumnTypes> {
5897
5857
  /**
5898
- * 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.
5899
5859
  *
5900
- * 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:
5901
5861
  *
5902
5862
  * ```ts
5863
+ * import { sql } from './baseTable';
5864
+ *
5903
5865
  * const result: { num: number }[] = await db.table.select({
5904
- * num: db.table.sql<number>`
5905
- * random() * 100
5906
- * `,
5866
+ * num: sql<number>`random() * 100`,
5907
5867
  * });
5908
5868
  * ```
5909
5869
  *
@@ -5912,20 +5872,10 @@ declare abstract class RawSqlMethods<ColumnTypes> {
5912
5872
  * This example assumes that the `timestamp` column was overridden with `asDate` as shown in [Override column types](/guide/columns-overview#override-column-types).
5913
5873
  *
5914
5874
  * ```ts
5915
- * const result: { timestamp: Date }[] = await db.table.select({
5916
- * timestamp: db.table.sql`now()`.type((t) => t.timestamp()),
5917
- * });
5918
- * ```
5919
- *
5920
- * Instead of `sql` method, you can use `raw` function from `orchid-orm` (or `pqb`) to do the same.
5921
- * The only difference, `raw` function don't have access to the overridden column types.
5922
- *
5923
- * ```ts
5924
- * import { raw } from 'orchid-orm';
5875
+ * import { sql } from './baseTable';
5925
5876
  *
5926
5877
  * const result: { timestamp: Date }[] = await db.table.select({
5927
- * // if you have overridden timestamp with `asDate` or `asNumber` it won't be parsed properly:
5928
- * timestamp: raw`now()`.type((t) => t.timestamp()),
5878
+ * timestamp: sql`now()`.type((t) => t.timestamp()),
5929
5879
  * });
5930
5880
  * ```
5931
5881
  *
@@ -5941,11 +5891,11 @@ declare abstract class RawSqlMethods<ColumnTypes> {
5941
5891
  * const result = await db.$from(subQuery).where({ sum: { gte: 5 } });
5942
5892
  * ```
5943
5893
  *
5944
- * `where` and other methods don't need the return type, so it can be omitted.
5945
- * 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`.
5946
5896
  *
5947
5897
  * ```ts
5948
- * await db.table.where`"someValue" = random() * 100`;
5898
+ * await db.table.whereSql`"someValue" = random() * 100`;
5949
5899
  * ```
5950
5900
  *
5951
5901
  * Interpolating values in template literals is completely safe:
@@ -5955,48 +5905,48 @@ declare abstract class RawSqlMethods<ColumnTypes> {
5955
5905
  * const { value } = req.params;
5956
5906
  *
5957
5907
  * // SQL injection is prevented by a library, this is safe:
5958
- * await db.table.where`column = ${value}`;
5908
+ * await db.table.whereSql`column = ${value}`;
5959
5909
  * ```
5960
5910
  *
5961
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.
5962
- * 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:
5963
5913
  *
5964
5914
  * ```ts
5965
- * import { raw } from 'orchid-orm';
5966
- *
5967
5915
  * // ids will be prefixed with proper table names, no ambiguity:
5968
5916
  * db.table.join(db.otherTable, 'id', 'otherId').where`
5969
5917
  * ${db.table.column('id')} = 1 AND
5970
- * ${db.otherTable.column('id')} = 2
5918
+ * ${db.otherTable.ref('id')} = 2
5971
5919
  * `;
5972
5920
  * ```
5973
5921
  *
5974
5922
  * SQL can be passed with a simple string, it's important to note that this is not safe to interpolate values in it.
5975
5923
  *
5976
5924
  * ```ts
5977
- * import { raw } from 'orchid-orm';
5925
+ * import { sql } from './baseTable';
5978
5926
  *
5979
5927
  * // no interpolation is okay
5980
- * await db.table.where(raw({ raw: 'column = random() * 100' }));
5928
+ * await db.table.where(sql({ raw: 'column = random() * 100' }));
5981
5929
  *
5982
5930
  * // get value from user-provided params
5983
5931
  * const { value } = req.params;
5984
5932
  *
5985
5933
  * // this is NOT safe, SQL injection is possible:
5986
- * await db.table.where(raw({ raw: `column = random() * ${value}` }));
5934
+ * await db.table.where(sql({ raw: `column = random() * ${value}` }));
5987
5935
  * ```
5988
5936
  *
5989
- * 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.
5990
5938
  *
5991
- * 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.
5992
5940
  *
5993
5941
  * ```ts
5942
+ * import { sql } from './baseTable';
5943
+ *
5994
5944
  * // get value from user-provided params
5995
5945
  * const { value } = req.params;
5996
5946
  *
5997
5947
  * // this is SAFE, SQL injection are prevented:
5998
5948
  * await db.table.where(
5999
- * db.table.sql({
5949
+ * sql<boolean>({
6000
5950
  * raw: '$$column = random() * $value',
6001
5951
  * values: {
6002
5952
  * column: 'someTable.someColumn', // or simply 'column'
@@ -6010,45 +5960,41 @@ declare abstract class RawSqlMethods<ColumnTypes> {
6010
5960
  * Summarizing:
6011
5961
  *
6012
5962
  * ```ts
5963
+ * import { sql } from './baseTable';
5964
+ *
6013
5965
  * // simplest form:
6014
- * db.table.sql`key = ${value}`;
5966
+ * sql`key = ${value}`;
6015
5967
  *
6016
5968
  * // with resulting type:
6017
- * db.table.sql<boolean>`key = ${value}`;
5969
+ * sql<boolean>`key = ${value}`;
6018
5970
  *
6019
5971
  * // with column type for select:
6020
- * db.table.sql`key = ${value}`.type((t) => t.boolean());
5972
+ * sql`key = ${value}`.type((t) => t.boolean());
6021
5973
  *
6022
5974
  * // with column name via `column` method:
6023
- * db.table.sql`${db.table.column('column')} = ${value}`;
5975
+ * sql`${db.table.column('column')} = ${value}`;
6024
5976
  *
6025
5977
  * // raw SQL string, not allowed to interpolate values:
6026
- * db.table.sql({ raw: 'random()' });
5978
+ * sql({ raw: 'random()' });
6027
5979
  *
6028
5980
  * // with resulting type and `raw` string:
6029
- * db.table.sql<number>({ raw: 'random()' });
5981
+ * sql<number>({ raw: 'random()' });
6030
5982
  *
6031
5983
  * // with column name and a value in a `raw` string:
6032
- * db.table.sql({
5984
+ * sql({
6033
5985
  * raw: `$$column = $value`,
6034
5986
  * values: { column: 'columnName', value: 123 },
6035
5987
  * });
6036
5988
  *
6037
5989
  * // combine template literal, column type, and values:
6038
- * db.table.sql`($one + $two) / $one`
6039
- * .type((t) => t.numeric())
6040
- * .values({ one: 1, two: 2 });
5990
+ * sql`($one + $two) / $one`.type((t) => t.numeric()).values({ one: 1, two: 2 });
6041
5991
  * ```
6042
5992
  *
6043
5993
  * @param args - template literal or an object { raw: string }
6044
5994
  * @return object that has `type` and `values` methods
6045
5995
  */
6046
- sql<T = unknown>(this: {
6047
- columnTypes: ColumnTypes;
6048
- }, ...args: StaticSQLArgs): RawSQL<QueryColumn<T>, ColumnTypes>;
6049
- sql<T = unknown>(this: {
6050
- columnTypes: ColumnTypes;
6051
- }, ...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>;
6052
5998
  }
6053
5999
 
6054
6000
  type QueryTransformFn<T extends Query> = (input: T['then'] extends QueryThen<infer Data> ? Data : never) => unknown;
@@ -6112,6 +6058,121 @@ declare class TransformMethods {
6112
6058
  transform<T extends Query, Fn extends QueryTransformFn<T>>(this: T, fn: Fn): QueryTransform<T, ReturnType<Fn>>;
6113
6059
  }
6114
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
+
6115
6176
  interface WindowArg<T extends OrderArgSelf> {
6116
6177
  [K: string]: WindowArgDeclaration<T> | Expression;
6117
6178
  }
@@ -6155,24 +6216,6 @@ type NarrowTypeResult<T extends PickQueryMetaResultReturnType, Narrow> = {
6155
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];
6156
6217
  } : T['result'][K];
6157
6218
  };
6158
- declare class ColumnRefExpression<T extends QueryColumn> extends Expression<T> {
6159
- name: string;
6160
- result: {
6161
- value: T;
6162
- };
6163
- q: ExpressionData;
6164
- constructor(value: T, name: string);
6165
- makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
6166
- }
6167
- declare class RefExpression<T extends QueryColumn> extends Expression<T> {
6168
- q: QueryData;
6169
- ref: string;
6170
- result: {
6171
- value: T;
6172
- };
6173
- constructor(value: T, q: QueryData, ref: string);
6174
- makeSQL(ctx: ToSQLCtx, quotedAs?: string): string;
6175
- }
6176
6219
  type WrapQueryArg = FromQuerySelf;
6177
6220
  declare const _queryAll: <T extends Query>(q: T) => SetQueryReturnsAll<T>;
6178
6221
  declare const _queryTake: <T extends PickQueryResult>(q: T) => SetQueryReturnsOne<T>;
@@ -6181,7 +6224,7 @@ declare const _queryExec: <T extends Query>(q: T) => never;
6181
6224
  declare const _queryFindBy: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOne<WhereResult<T>>;
6182
6225
  declare const _queryFindByOptional: <T extends QueryBase<EmptyObject>>(q: T, args: WhereArg<T>[]) => SetQueryReturnsOneOptional<WhereResult<T>>;
6183
6226
  declare const _queryRows: <T extends Query>(q: T) => SetQueryReturnsRows<T>;
6184
- 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, 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 {
6185
6228
  }
6186
6229
  declare class QueryMethods<ColumnTypes> {
6187
6230
  /**
@@ -6282,11 +6325,13 @@ declare class QueryMethods<ColumnTypes> {
6282
6325
  * db.table.distinct().select('name');
6283
6326
  * ```
6284
6327
  *
6285
- * 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 (...)`:
6286
6329
  *
6287
6330
  * ```ts
6331
+ * import { sql } from './baseTable';
6332
+ *
6288
6333
  * // Distinct on the name and raw SQL
6289
- * db.table.distinct('name', db.table.sql`raw sql`).select('id', 'name');
6334
+ * db.table.distinct('name', sql`raw sql`).select('id', 'name');
6290
6335
  * ```
6291
6336
  *
6292
6337
  * @param columns - column names or a raw SQL
@@ -6404,9 +6449,11 @@ declare class QueryMethods<ColumnTypes> {
6404
6449
  * Also, it's possible to group by a selected value:
6405
6450
  *
6406
6451
  * ```ts
6452
+ * import { sql } from './baseTable';
6453
+ *
6407
6454
  * const results = db.product
6408
6455
  * .select({
6409
- * month: db.product.sql`extract(month from "createdAt")`.type((t) =>
6456
+ * month: sql`extract(month from "createdAt")`.type((t) =>
6410
6457
  * // month is returned as string, parse it to int
6411
6458
  * t.string().parse(parseInt),
6412
6459
  * ),
@@ -6490,8 +6537,6 @@ declare class QueryMethods<ColumnTypes> {
6490
6537
  *
6491
6538
  * ```ts
6492
6539
  * db.table.orderSql`raw sql`;
6493
- * // or
6494
- * db.table.orderSql(db.table.sql`raw sql`);
6495
6540
  * ```
6496
6541
  *
6497
6542
  * @param args - SQL expression
@@ -6653,50 +6698,6 @@ declare class QueryMethods<ColumnTypes> {
6653
6698
  * @param fn - helper function
6654
6699
  */
6655
6700
  makeHelper<T extends PickQueryMetaShape, Args extends unknown[], Result>(this: T, fn: (q: T, ...args: Args) => Result): QueryHelper<T, Args, Result>;
6656
- /**
6657
- * `column` references a table column, this can be used in raw SQL or when building a column expression.
6658
- * Only for referencing a column in the query's table. For referencing joined table's columns, see [ref](#ref).
6659
- *
6660
- * ```ts
6661
- * await db.table.select({
6662
- * // select `("table"."id" = 1 OR "table"."name" = 'name') AS "one"`,
6663
- * // returns a boolean
6664
- * one: (q) =>
6665
- * q.sql<boolean>`${q.column('id')} = ${1} OR ${q.column('name')} = ${'name'}`,
6666
- *
6667
- * // selects the same as above, but by building a query
6668
- * two: (q) => q.column('id').equals(1).or(q.column('name').equals('name')),
6669
- * });
6670
- * ```
6671
- *
6672
- * @param name - column name
6673
- */
6674
- column<T extends PickQueryShape, K extends keyof T['shape']>(this: T, name: K): ColumnRefExpression<T['shape'][K]> & T['shape'][K]['operators'];
6675
- /**
6676
- * `ref` is similar to [column](#column), but it also allows to reference a column of joined table,
6677
- * and other dynamically defined columns.
6678
- *
6679
- * ```ts
6680
- * await db.table.join('otherTable').select({
6681
- * // select `("otherTable"."id" = 1 OR "otherTable"."name" = 'name') AS "one"`,
6682
- * // returns a boolean
6683
- * one: (q) =>
6684
- * q.sql<boolean>`${q.ref('otherTable.id')} = ${1} OR ${q.ref(
6685
- * 'otherTable.name',
6686
- * )} = ${'name'}`,
6687
- *
6688
- * // selects the same as above, but by building a query
6689
- * two: (q) =>
6690
- * q
6691
- * .ref('otherTable.id')
6692
- * .equals(1)
6693
- * .or(q.ref('otherTable.name').equals('name')),
6694
- * });
6695
- * ```
6696
- *
6697
- * @param arg - any available column name, such as of a joined table
6698
- */
6699
- 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'];
6700
6701
  /**
6701
6702
  * Narrows a part of the query output type.
6702
6703
  * Use with caution, type-safety isn't guaranteed with it.
@@ -6823,9 +6824,11 @@ interface PickQueryMetaResultRelations extends PickQueryResult, PickQueryMeta, P
6823
6824
  }
6824
6825
  interface PickQueryMetaResultRelationsWindows extends PickQueryMetaResultRelations, PickQueryWindows {
6825
6826
  }
6826
- interface PickQueryMetaResultRelationsWindowsColumnTypes extends PickQueryMetaResultRelationsWindows {
6827
+ interface PickQueryColumnTypes {
6827
6828
  columnTypes: unknown;
6828
6829
  }
6830
+ interface PickQueryMetaResultRelationsWindowsColumnTypes extends PickQueryMetaResultRelationsWindows, PickQueryColumnTypes {
6831
+ }
6829
6832
  interface PickQueryMetaTable extends PickQueryMeta, PickQueryTable {
6830
6833
  }
6831
6834
  interface PickQueryMetaTableShape extends PickQueryMetaTable, PickQueryShape {
@@ -7670,4 +7673,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
7670
7673
  */
7671
7674
  declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
7672
7675
 
7673
- 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 };