pqb 0.11.8 → 0.11.10

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 { Sql, EmptyObject, RawExpression, ColumnTypeBase, MaybeArray, QueryResultRow, AdapterBase, QueryInput, ColumnsShapeBase, StringKey, ColumnOutput, NullableColumn, QueryInternal, QueryMetaBase, EmptyTuple, ColumnTypesBase, DbBase, ThenResult, ColumnShapeOutput, DefaultSelectColumns, SetOptional, Spread, CoalesceString, QueryBaseCommon, QueryCommon, BaseNumberData, Code, numberTypeMethods, BaseStringData, PrimaryKeyColumn, DateColumnData, EncodeColumn, ParseColumn, dateTypeMethods, JSONTypeAny, record, ArrayMethodsData, arrayMethods, name, ColumnDataBase, BaseOperators, HiddenColumn, ValidationContext, MessageParam } from 'orchid-core';
2
+ import { Sql, QueryBaseCommon, ColumnsShapeBase, QueryInternal, QueryMetaBase, EmptyObject, RawExpression, ColumnTypeBase, MaybeArray, QueryResultRow, AdapterBase, QueryInput, StringKey, ColumnOutput, NullableColumn, EmptyTuple, ColumnTypesBase, DbBase, ThenResult, ColumnShapeOutput, DefaultSelectColumns, SetOptional, Spread, CoalesceString, QueryCommon, BaseNumberData, Code, numberTypeMethods, BaseStringData, PrimaryKeyColumn, DateColumnData, EncodeColumn, ParseColumn, dateTypeMethods, JSONTypeAny, record, ArrayMethodsData, arrayMethods, name, ColumnDataBase, BaseOperators, HiddenColumn, ValidationContext, MessageParam } from 'orchid-core';
3
3
  import { PoolConfig, Pool, PoolClient } from 'pg';
4
4
  import { inspect } from 'util';
5
5
  import { AsyncLocalStorage } from 'node:async_hooks';
@@ -19,6 +19,20 @@ type ToSqlOptions = {
19
19
  declare const toSql: (table: Query, options?: ToSqlOptions) => Sql;
20
20
  declare const makeSql: (table: Query, { values }?: ToSqlOptions) => Sql;
21
21
 
22
+ declare abstract class QueryBase implements QueryBaseCommon {
23
+ clone<T extends QueryBase>(this: T): T;
24
+ abstract result: ColumnsShape;
25
+ query: QueryData;
26
+ table?: string;
27
+ selectable: SelectableBase;
28
+ shape: ColumnsShapeBase;
29
+ relations: RelationsBase;
30
+ withData: WithDataBase;
31
+ baseQuery: Query;
32
+ internal: QueryInternal;
33
+ meta: QueryMetaBase;
34
+ }
35
+
22
36
  type BaseRelation = {
23
37
  type: string;
24
38
  key: string;
@@ -561,18 +575,7 @@ declare const addWhereNot: <T extends QueryBase>(q: T, args: WhereArg<T>[]) => W
561
575
  declare const addOr: <T extends QueryBase>(q: T, args: WhereArg<T>[]) => WhereResult<T>;
562
576
  declare const addOrNot: <T extends QueryBase>(q: T, args: WhereArg<T>[]) => WhereResult<T>;
563
577
  declare const addWhereIn: <T extends QueryBase>(q: T, and: boolean, arg: unknown, values: unknown[] | unknown[][] | Query | RawExpression | undefined, not?: boolean) => WhereResult<T>;
564
- declare abstract class Where implements QueryBase {
565
- abstract clone<T extends this>(this: T): T;
566
- abstract selectable: SelectableBase;
567
- abstract shape: ColumnsShapeBase;
568
- abstract relations: RelationsBase;
569
- abstract withData: WithDataBase;
570
- abstract baseQuery: Query;
571
- abstract internal: QueryInternal;
572
- query: QueryData;
573
- table?: string;
574
- meta: QueryMetaBase;
575
- result: ColumnsShape;
578
+ declare abstract class Where extends QueryBase {
576
579
  where<T extends Where>(this: T, ...args: WhereArg<T>[]): WhereResult<T>;
577
580
  _where<T extends Where>(this: T, ...args: WhereArg<T>[]): WhereResult<T>;
578
581
  whereNot<T extends Where>(this: T, ...args: WhereArg<T>[]): WhereResult<T>;
@@ -620,18 +623,17 @@ declare abstract class Where implements QueryBase {
620
623
  }
621
624
  declare class WhereQueryBuilder<Q extends QueryBase = QueryBase> extends Where implements QueryBase {
622
625
  selectable: Q['selectable'];
623
- shape: Q['shape'];
624
626
  relations: Q['relations'];
627
+ result: Q['result'];
628
+ shape: Q['shape'];
625
629
  baseQuery: Query;
626
630
  withData: {};
627
631
  internal: Q['internal'];
628
- result: Q['result'];
629
632
  constructor(q: QueryBase, { shape, joinedShapes }: Pick<QueryData, 'shape' | 'joinedShapes'>);
630
- clone<T extends this>(this: T): T;
631
633
  }
632
634
 
633
635
  type WithSelectable<T extends QueryBase, W extends keyof T['withData']> = T['withData'][W] extends WithDataItem ? StringKey<keyof T['withData'][W]['shape']> | `${T['withData'][W]['table']}.${StringKey<keyof T['withData'][W]['shape']>}` : never;
634
- type JoinFirstArg<T extends QueryBase> = Query | keyof T['relations'] | keyof T['withData'];
636
+ type JoinFirstArg<T extends QueryBase> = Query | keyof T['relations'] | keyof T['withData'] | ((q: Pick<T, keyof T['relations']>) => Query);
635
637
  type JoinArgs<T extends QueryBase, Arg extends JoinFirstArg<T>> = Arg extends Query ? JoinQueryArgs<T, Arg> : Arg extends keyof T['relations'] ? EmptyTuple : Arg extends keyof T['withData'] ? JoinWithArgs<T, Arg> : never;
636
638
  type JoinSelectable<Q extends Query> = keyof Q['result'] | `${AliasOrTable<Q>}.${StringKey<keyof Q['result']>}`;
637
639
  type JoinQueryArgs<T extends QueryBase, Q extends Query> = [
@@ -654,15 +656,31 @@ type JoinWithArgs<T extends QueryBase, W extends keyof T['withData']> = [
654
656
  op: string,
655
657
  rightColumn: Selectable<T> | RawExpression
656
658
  ];
657
- type JoinResult<T extends Query, Arg extends JoinFirstArg<T>, RequireJoined extends boolean, RequireMain extends boolean, J extends Pick<Query, 'result' | 'table' | 'meta'> = Arg extends Query ? Arg : T['relations'] extends Record<string, Relation> ? Arg extends keyof T['relations'] ? T['relations'][Arg]['table'] : Arg extends keyof T['withData'] ? T['withData'][Arg] extends WithDataItem ? {
659
+ type JoinResult<T extends Query, Arg extends JoinFirstArg<T>, RequireJoined extends boolean, RequireMain extends boolean, Cb extends (q: never) => {
660
+ meta: {
661
+ as?: string;
662
+ };
663
+ } = () => {
664
+ meta: EmptyObject;
665
+ }, J extends Pick<Query, 'result' | 'table' | 'meta'> = Arg extends Query ? Arg : T['relations'] extends Record<string, Relation> ? Arg extends keyof T['relations'] ? T['relations'][Arg]['table'] : Arg extends (q: never) => Query ? ReturnType<Arg> : Arg extends keyof T['withData'] ? T['withData'][Arg] extends WithDataItem ? {
658
666
  table: T['withData'][Arg]['table'];
659
667
  result: T['withData'][Arg]['shape'];
660
668
  meta: EmptyObject;
661
- } : never : never : never, Selectable extends SelectableBase = JoinResultSelectable<J, RequireJoined>> = RequireMain extends true ? JoinAddSelectable<T, Selectable> : JoinOptionalMain<T, Selectable>;
662
- type JoinLateralResult<T extends Query, R extends QueryBase, RequireJoined extends boolean, RequireMain extends boolean, Selectable extends SelectableBase = JoinResultSelectable<R, RequireJoined>> = RequireMain extends true ? JoinAddSelectable<T, Selectable> : JoinOptionalMain<T, Selectable>;
663
- type JoinResultSelectable<J extends Pick<Query, 'result' | 'table' | 'meta'>, RequireJoined extends boolean, Result extends ColumnsShape = RequireJoined extends true ? J['result'] : {
669
+ } : never : never : never, Selectable extends SelectableBase = JoinResultSelectable<J, RequireJoined, ReturnType<Cb>>> = RequireMain extends true ? JoinAddSelectable<T, Selectable> : JoinOptionalMain<T, Selectable>;
670
+ type JoinLateralResult<T extends Query, R extends QueryBase, RequireJoined extends boolean, RequireMain extends boolean, Selectable extends SelectableBase = JoinResultSelectable<R, RequireJoined, {
671
+ meta: EmptyObject;
672
+ }>> = RequireMain extends true ? JoinAddSelectable<T, Selectable> : JoinOptionalMain<T, Selectable>;
673
+ type JoinResultSelectable<J extends Pick<Query, 'result' | 'table' | 'meta'>, RequireJoined extends boolean, CbResult extends {
674
+ meta: {
675
+ as?: string;
676
+ };
677
+ }, Result extends ColumnsShape = RequireJoined extends true ? J['result'] : {
664
678
  [K in keyof J['result']]: NullableColumn<J['result'][K]>;
665
- }, As extends string = AliasOrTable<J>> = {
679
+ }, As extends string = CbResult extends {
680
+ meta: {
681
+ as: string;
682
+ };
683
+ } ? CbResult['meta']['as'] : AliasOrTable<J>> = {
666
684
  [K in keyof Result as `${As}.${StringKey<K>}`]: {
667
685
  as: K;
668
686
  column: Result[K];
@@ -694,7 +712,7 @@ type JoinWithArgToQuery<With extends WithDataItem, Selectable extends Selectable
694
712
  }> = {
695
713
  query: QueryData;
696
714
  table: With['table'];
697
- clone(): QueryBase;
715
+ clone<T extends QueryBase>(this: T): T;
698
716
  selectable: Selectable & {
699
717
  [K in keyof Selectable as `${With['table']}.${StringKey<K>}`]: Selectable[K];
700
718
  };
@@ -711,21 +729,21 @@ type JoinCallback<T extends QueryBase, Arg extends JoinFirstArg<T>> = (q: OnQuer
711
729
  type JoinLateralCallback<T extends QueryBase, Arg extends JoinFirstArg<T>, R extends QueryBase, Q extends QueryBase = JoinArgToQuery<T, Arg>> = (q: Q & OnQueryBuilder<T, Q>) => R;
712
730
  declare class Join {
713
731
  join<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, true, true>;
714
- join<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, true, true>;
732
+ join<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, true, true, Cb>;
715
733
  _join<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, true, true>;
716
- _join<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, true, true>;
734
+ _join<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, true, true, Cb>;
717
735
  leftJoin<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, false, true>;
718
- leftJoin<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, false, true>;
736
+ leftJoin<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, false, true, Cb>;
719
737
  _leftJoin<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, false, true>;
720
- _leftJoin<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, false, true>;
738
+ _leftJoin<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, false, true, Cb>;
721
739
  rightJoin<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, true, false>;
722
- rightJoin<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, true, false>;
740
+ rightJoin<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, true, false, Cb>;
723
741
  _rightJoin<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, true, false>;
724
- _rightJoin<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, true, false>;
742
+ _rightJoin<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, true, false, Cb>;
725
743
  fullJoin<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, false, false>;
726
- fullJoin<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, false, false>;
744
+ fullJoin<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, false, false, Cb>;
727
745
  _fullJoin<T extends Query, Arg extends JoinFirstArg<T>, Args extends JoinArgs<T, Arg>>(this: T, arg: Arg, ...args: Args): JoinResult<T, Arg, false, false>;
728
- _fullJoin<T extends Query, Arg extends JoinFirstArg<T>>(this: T, arg: Arg, cb: JoinCallback<T, Arg>): JoinResult<T, Arg, false, false>;
746
+ _fullJoin<T extends Query, Arg extends JoinFirstArg<T>, Cb extends JoinCallback<T, Arg>>(this: T, arg: Arg, cb: Cb): JoinResult<T, Arg, false, false, Cb>;
729
747
  joinLateral<T extends Query, Arg extends JoinFirstArg<T>, R extends QueryBase>(this: T, arg: Arg, cb: JoinLateralCallback<T, Arg, R>): JoinLateralResult<T, R, true, true>;
730
748
  _joinLateral<T extends Query, Arg extends JoinFirstArg<T>, R extends QueryBase>(this: T, arg: Arg, cb: JoinLateralCallback<T, Arg, R>): JoinLateralResult<T, R, true, true>;
731
749
  leftJoinLateral<T extends Query, Arg extends JoinFirstArg<T>, R extends QueryBase>(this: T, arg: Arg, cb: JoinLateralCallback<T, Arg, R>): JoinLateralResult<T, R, false, true>;
@@ -839,6 +857,7 @@ interface Db<Table extends string | undefined = undefined, Shape extends Columns
839
857
  windows: Query['windows'];
840
858
  defaultSelectColumns: DefaultSelectColumns<Shape>;
841
859
  relations: Relations;
860
+ relationsQueries: Record<string, Query>;
842
861
  withData: Query['withData'];
843
862
  error: new (message: string, length: number, name: QueryErrorName) => QueryError<this>;
844
863
  isSubQuery: false;
@@ -862,7 +881,7 @@ type DbResult<CT extends ColumnTypesBase> = Db<string, Record<string, never>, Qu
862
881
  adapter: Adapter;
863
882
  close: Adapter['close'];
864
883
  };
865
- declare const createDb: <CT extends ColumnTypesBase>({ log, logger, columnTypes: ctOrFn, snakeCase, ...options }: DbOptions<CT>) => DbResult<CT>;
884
+ declare const createDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ log, logger, columnTypes: ctOrFn, snakeCase, ...options }: DbOptions<CT>) => DbResult<CT>;
866
885
 
867
886
  type WithArgsOptions = Omit<WithOptions, 'columns'> & {
868
887
  columns?: boolean | string[];
@@ -1341,6 +1360,11 @@ declare class CopyMethods {
1341
1360
  _copy<T extends Query>(this: T, arg: CopyArg<T>): T;
1342
1361
  }
1343
1362
 
1363
+ declare abstract class AsMethods extends QueryBase {
1364
+ as<T extends AsMethods, As extends string>(this: T, as: As): SetQueryTableAlias<T, As>;
1365
+ _as<T extends AsMethods, As extends string>(this: T, as: As): SetQueryTableAlias<T, As>;
1366
+ }
1367
+
1344
1368
  type WindowArg<T extends Query> = Record<string, WindowArgDeclaration<T> | RawExpression>;
1345
1369
  type WindowArgDeclaration<T extends Query = Query> = {
1346
1370
  partitionBy?: Expression<T> | Expression<T>[];
@@ -1352,7 +1376,7 @@ type OrderArg<T extends Query, Key extends PropertyKey = keyof T['selectable'] |
1352
1376
  }[keyof T['result']]> = Key | {
1353
1377
  [K in Key]?: SortDir;
1354
1378
  } | RawExpression;
1355
- interface QueryMethods extends Aggregate, Select, From, Join, With, Union, Json, Create, Update, Delete, Transaction, For, ColumnInfoMethods, Omit<Where, 'result'>, Clear, Having, Window, Then, QueryLog, QueryCallbacks, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, RawMethods, CopyMethods {
1379
+ interface QueryMethods extends Omit<AsMethods, 'result'>, Aggregate, Select, From, Join, With, Union, Json, Create, Update, Delete, Transaction, For, ColumnInfoMethods, Omit<Where, 'result'>, Clear, Having, Window, Then, QueryLog, QueryCallbacks, QueryUpsertOrCreate, QueryGet, MergeQueryMethods, RawMethods, CopyMethods {
1356
1380
  }
1357
1381
  declare class QueryMethods {
1358
1382
  windows: EmptyObject;
@@ -1369,7 +1393,6 @@ declare class QueryMethods {
1369
1393
  _pluck<T extends Query, S extends Expression<T>>(this: T, select: S): SetQueryReturnsPluck<T, S>;
1370
1394
  exec<T extends Query>(this: T): SetQueryReturnsVoid<T>;
1371
1395
  _exec<T extends Query>(this: T): SetQueryReturnsVoid<T>;
1372
- clone<T extends QueryBase>(this: T): T;
1373
1396
  toSql(this: Query, options?: ToSqlOptions): Sql;
1374
1397
  distinct<T extends Query>(this: T, ...columns: Expression<T>[]): T;
1375
1398
  _distinct<T extends Query>(this: T, ...columns: Expression<T>[]): T;
@@ -1381,8 +1404,6 @@ declare class QueryMethods {
1381
1404
  _findBy<T extends Query>(this: T, ...args: WhereArg<T>[]): SetQueryReturnsOne<WhereResult<T>>;
1382
1405
  findByOptional<T extends Query>(this: T, ...args: WhereArg<T>[]): SetQueryReturnsOneOptional<WhereResult<T>>;
1383
1406
  _findByOptional<T extends Query>(this: T, ...args: WhereArg<T>[]): SetQueryReturnsOneOptional<WhereResult<T>>;
1384
- as<T extends Query, As extends string>(this: T, as: As): SetQueryTableAlias<T, As>;
1385
- _as<T extends Query, As extends string>(this: T, as: As): SetQueryTableAlias<T, As>;
1386
1407
  withSchema<T extends Query>(this: T, schema: string): T;
1387
1408
  _withSchema<T extends Query>(this: T, schema: string): T;
1388
1409
  group<T extends Query>(this: T, ...columns: Expression<T>[]): T;
@@ -1565,17 +1586,6 @@ type WithDataItem = {
1565
1586
  shape: ColumnsShape;
1566
1587
  };
1567
1588
  type WithDataBase = Record<never, WithDataItem>;
1568
- type QueryBase = QueryBaseCommon & {
1569
- query: QueryData;
1570
- table?: string;
1571
- clone(): QueryBase;
1572
- selectable: SelectableBase;
1573
- shape: ColumnsShapeBase;
1574
- result: ColumnsShape;
1575
- baseQuery: Query;
1576
- relations: RelationsBase;
1577
- withData: WithDataBase;
1578
- };
1579
1589
  type defaultsKey = typeof defaultsKey;
1580
1590
  declare const defaultsKey: unique symbol;
1581
1591
  type Query = QueryCommon & QueryMethods & {
@@ -1597,6 +1607,7 @@ type Query = QueryCommon & QueryMethods & {
1597
1607
  windows: EmptyObject;
1598
1608
  defaultSelectColumns: string[];
1599
1609
  relations: RelationsBase;
1610
+ relationsQueries: Record<string, Query>;
1600
1611
  withData: WithDataBase;
1601
1612
  error: new (message: string, length: number, name: QueryErrorName) => QueryError;
1602
1613
  isSubQuery: boolean;
@@ -1674,7 +1685,9 @@ type SetQueryReturnsColumnInfo<T extends Query, Column extends keyof T['shape']
1674
1685
  returnType: 'value';
1675
1686
  then: ThenResult<Result>;
1676
1687
  };
1677
- type SetQueryTableAlias<T extends Query, As extends string> = {
1688
+ type SetQueryTableAlias<T extends Pick<Query, 'selectable' | 'table' | 'meta'> & {
1689
+ shape: ColumnsShapeBase;
1690
+ }, As extends string> = {
1678
1691
  [K in keyof T]: K extends 'selectable' ? Omit<T['selectable'], `${AliasOrTable<T>}.${StringKey<keyof T['shape']>}`> & {
1679
1692
  [K in keyof T['shape'] as `${As}.${StringKey<keyof T['shape']>}`]: {
1680
1693
  as: K;
@@ -1901,7 +1914,7 @@ declare abstract class ColumnsObject<Shape extends ColumnsShape> extends ColumnT
1901
1914
  type: any[] | orchid_core.RawExpression | Query;
1902
1915
  };
1903
1916
  };
1904
- constructor(types: ColumnTypesBase, shape: Shape);
1917
+ constructor(shape: Shape);
1905
1918
  }
1906
1919
  declare abstract class ArrayOfColumnsObjects<Shape extends ColumnsShape> extends ColumnType<{
1907
1920
  [K in keyof Shape]: Shape[K]['type'];
@@ -1922,7 +1935,7 @@ declare abstract class ArrayOfColumnsObjects<Shape extends ColumnsShape> extends
1922
1935
  type: any[] | orchid_core.RawExpression | Query;
1923
1936
  };
1924
1937
  };
1925
- constructor(types: ColumnTypesBase, shape: Shape);
1938
+ constructor(shape: Shape);
1926
1939
  }
1927
1940
  declare abstract class PluckResultColumnType<C extends ColumnType> extends ColumnType<C['type'][], typeof Operators.any> {
1928
1941
  }
@@ -1971,7 +1984,7 @@ declare abstract class NumberBaseColumn extends ColumnType<number, typeof Operat
1971
1984
  }
1972
1985
  declare abstract class IntegerBaseColumn extends NumberBaseColumn {
1973
1986
  data: NumberColumnData;
1974
- constructor(types: ColumnTypesBase);
1987
+ constructor();
1975
1988
  }
1976
1989
  declare abstract class NumberAsStringBaseColumn extends ColumnType<string, typeof Operators.number> {
1977
1990
  operators: {
@@ -2040,7 +2053,7 @@ declare class DecimalBaseColumn<Precision extends number | undefined = undefined
2040
2053
  };
2041
2054
  };
2042
2055
  dataType: "decimal";
2043
- constructor(types: ColumnTypesBase, numericPrecision?: Precision, numericScale?: Scale);
2056
+ constructor(numericPrecision?: Precision, numericScale?: Scale);
2044
2057
  toCode(t: string): Code;
2045
2058
  toSQL(): string;
2046
2059
  }
@@ -2076,7 +2089,7 @@ declare class SmallSerialColumn extends IntegerBaseColumn {
2076
2089
  dataType: "smallint";
2077
2090
  parseItem: typeof parseInt;
2078
2091
  data: SerialColumnData;
2079
- constructor(types: ColumnTypesBase);
2092
+ constructor();
2080
2093
  toSQL(): string;
2081
2094
  toCode(t: string): Code;
2082
2095
  }
@@ -2084,7 +2097,7 @@ declare class SerialColumn extends IntegerBaseColumn {
2084
2097
  dataType: "integer";
2085
2098
  parseItem: typeof parseInt;
2086
2099
  data: SerialColumnData;
2087
- constructor(types: ColumnTypesBase);
2100
+ constructor();
2088
2101
  toSQL(): string;
2089
2102
  toCode(t: string): Code;
2090
2103
  }
@@ -2336,7 +2349,7 @@ declare abstract class LimitedTextBaseColumn<Limit extends number | undefined =
2336
2349
  data: TextColumnData & {
2337
2350
  maxChars: Limit;
2338
2351
  };
2339
- constructor(types: ColumnTypesBase, limit?: Limit);
2352
+ constructor(limit?: Limit);
2340
2353
  toSQL(): string;
2341
2354
  }
2342
2355
  declare class VarCharColumn<Limit extends number | undefined = undefined> extends LimitedTextBaseColumn<Limit> {
@@ -2353,7 +2366,7 @@ declare class TextColumn extends TextBaseColumn {
2353
2366
  minArg?: number;
2354
2367
  maxArg?: number;
2355
2368
  };
2356
- constructor(types: ColumnTypesBase, minArg?: number, maxArg?: number);
2369
+ constructor(minArg?: number, maxArg?: number);
2357
2370
  toCode(t: string): Code;
2358
2371
  }
2359
2372
  declare class ByteaColumn extends ColumnType<Buffer, typeof Operators.text> {
@@ -2832,7 +2845,7 @@ declare class BitColumn<Length extends number> extends ColumnType<string, typeof
2832
2845
  data: ColumnData & {
2833
2846
  length: Length;
2834
2847
  };
2835
- constructor(types: ColumnTypesBase, length: Length);
2848
+ constructor(length: Length);
2836
2849
  toCode(t: string): Code;
2837
2850
  toSQL(): string;
2838
2851
  }
@@ -2873,7 +2886,7 @@ declare class BitVaryingColumn<Length extends number | undefined = undefined> ex
2873
2886
  data: ColumnData & {
2874
2887
  length: Length;
2875
2888
  };
2876
- constructor(types: ColumnTypesBase, length?: Length);
2889
+ constructor(length?: Length);
2877
2890
  toCode(t: string): Code;
2878
2891
  toSQL(): string;
2879
2892
  }
@@ -3028,7 +3041,7 @@ declare class CitextColumn extends TextBaseColumn {
3028
3041
  minArg?: number;
3029
3042
  maxArg?: number;
3030
3043
  };
3031
- constructor(types: ColumnTypesBase, minArg?: number, maxArg?: number);
3044
+ constructor(minArg?: number, maxArg?: number);
3032
3045
  toCode(t: string): Code;
3033
3046
  }
3034
3047
 
@@ -3078,7 +3091,7 @@ declare abstract class DateTimeBaseClass<Precision extends number | undefined =
3078
3091
  data: DateColumnData & {
3079
3092
  dateTimePrecision: Precision;
3080
3093
  };
3081
- constructor(types: ColumnTypesBase, dateTimePrecision?: Precision);
3094
+ constructor(dateTimePrecision?: Precision);
3082
3095
  toSQL(): string;
3083
3096
  }
3084
3097
  declare abstract class DateTimeTzBaseClass<Precision extends number | undefined = undefined> extends DateTimeBaseClass<Precision> {
@@ -3141,7 +3154,7 @@ declare class IntervalColumn<Fields extends string | undefined = undefined, Prec
3141
3154
  type: orchid_core.RawExpression | Query | Date[];
3142
3155
  };
3143
3156
  };
3144
- constructor(types: ColumnTypesBase, fields?: Fields, precision?: Precision);
3157
+ constructor(fields?: Fields, precision?: Precision);
3145
3158
  toCode(t: string): Code;
3146
3159
  toSQL(): string;
3147
3160
  }
@@ -3184,7 +3197,7 @@ declare class EnumColumn<U extends string = string, T extends [U, ...U[]] = [U]>
3184
3197
  };
3185
3198
  };
3186
3199
  dataType: string;
3187
- constructor(types: ColumnTypesBase, enumName: string, options: T);
3200
+ constructor(enumName: string, options: T);
3188
3201
  toCode(t: string, migration?: boolean): Code;
3189
3202
  toSQL(): string;
3190
3203
  }
@@ -3251,7 +3264,7 @@ declare class JSONColumn<Type extends JSONTypeAny = JSONTypeAny> extends ColumnT
3251
3264
  data: ColumnData & {
3252
3265
  schema: Type;
3253
3266
  };
3254
- constructor(types: ColumnTypesBase, schemaOrFn?: Type | ((j: JSONTypes) => Type));
3267
+ constructor(schemaOrFn?: Type | ((j: JSONTypes) => Type));
3255
3268
  toCode(t: string): Code;
3256
3269
  }
3257
3270
  declare class JSONTextColumn extends ColumnType<string, typeof Operators.text> {
@@ -3314,7 +3327,7 @@ declare class ArrayColumn<Item extends ColumnType> extends ColumnType<Item['type
3314
3327
  };
3315
3328
  };
3316
3329
  data: ArrayData<Item>;
3317
- constructor(types: ColumnTypesBase, item: Item);
3330
+ constructor(item: Item);
3318
3331
  toSQL(): string;
3319
3332
  toCode(this: ArrayColumn<Item>, t: string): Code;
3320
3333
  parseFn: ((input: unknown) => unknown[]) & {
@@ -3338,7 +3351,7 @@ declare class CustomTypeColumn extends ColumnType<unknown, typeof Operators.any>
3338
3351
  type: any[] | orchid_core.RawExpression | Query;
3339
3352
  };
3340
3353
  };
3341
- constructor(types: ColumnTypesBase, dataType: string);
3354
+ constructor(dataType: string);
3342
3355
  toCode(t: string): Code;
3343
3356
  }
3344
3357
  declare class DomainColumn extends CustomTypeColumn {
@@ -3394,8 +3407,8 @@ declare const getConstraintKind: (it: TableData.Constraint) => 'constraint' | 'f
3394
3407
  declare const newTableData: () => TableData;
3395
3408
  declare const getTableData: () => TableData;
3396
3409
  declare const resetTableData: (data?: TableData) => void;
3397
- declare const getColumnTypes: <CT extends ColumnTypesBase, Shape extends ColumnsShape>(types: CT, fn: (t: CT) => Shape, data?: TableData) => Shape;
3398
- declare function text(this: ColumnTypesBase, min: number, max: number): TextColumn;
3410
+ declare const getColumnTypes: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>, Shape extends ColumnsShape>(types: CT, fn: (t: CT) => Shape, data?: TableData) => Shape;
3411
+ declare function text(min: number, max: number): TextColumn;
3399
3412
  type DefaultColumnTypes = typeof columnTypes;
3400
3413
  declare const columnTypes: {
3401
3414
  timestamps: <T extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
@@ -3418,53 +3431,53 @@ declare const columnTypes: {
3418
3431
  };
3419
3432
  name: typeof name;
3420
3433
  raw: (sql: string, values?: false | Record<string, unknown> | undefined) => RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>;
3421
- smallint(this: ColumnTypesBase): SmallIntColumn;
3422
- integer(this: ColumnTypesBase): IntegerColumn;
3423
- bigint(this: ColumnTypesBase): BigIntColumn;
3424
- numeric<Precision extends number | undefined = undefined, Scale extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision | undefined, scale?: Scale | undefined): DecimalColumn<Precision, Scale>;
3425
- decimal<Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_1 | undefined, scale?: Scale_1 | undefined): DecimalColumn<Precision_1, Scale_1>;
3426
- real(this: ColumnTypesBase): RealColumn;
3427
- doublePrecision(this: ColumnTypesBase): DoublePrecisionColumn;
3428
- identity(this: ColumnTypesBase, options?: TableData.Identity): IntegerColumn;
3429
- smallSerial(this: ColumnTypesBase): SmallSerialColumn;
3430
- serial(this: ColumnTypesBase): SerialColumn;
3431
- bigSerial(this: ColumnTypesBase): BigSerialColumn;
3432
- money(this: ColumnTypesBase): MoneyColumn;
3433
- varchar<Limit extends number | undefined = undefined>(this: ColumnTypesBase, limit?: Limit | undefined): VarCharColumn<Limit>;
3434
- char<Limit_1 extends number | undefined = undefined>(this: ColumnTypesBase, limit?: Limit_1 | undefined): CharColumn<Limit_1>;
3434
+ smallint(): SmallIntColumn;
3435
+ integer(): IntegerColumn;
3436
+ bigint(): BigIntColumn;
3437
+ numeric<Precision extends number | undefined = undefined, Scale extends number | undefined = undefined>(precision?: Precision | undefined, scale?: Scale | undefined): DecimalColumn<Precision, Scale>;
3438
+ decimal<Precision_1 extends number | undefined = undefined, Scale_1 extends number | undefined = undefined>(precision?: Precision_1 | undefined, scale?: Scale_1 | undefined): DecimalColumn<Precision_1, Scale_1>;
3439
+ real(): RealColumn;
3440
+ doublePrecision(): DoublePrecisionColumn;
3441
+ identity(options?: TableData.Identity): IntegerColumn;
3442
+ smallSerial(): SmallSerialColumn;
3443
+ serial(): SerialColumn;
3444
+ bigSerial(): BigSerialColumn;
3445
+ money(): MoneyColumn;
3446
+ varchar<Limit extends number | undefined = undefined>(limit?: Limit | undefined): VarCharColumn<Limit>;
3447
+ char<Limit_1 extends number | undefined = undefined>(limit?: Limit_1 | undefined): CharColumn<Limit_1>;
3435
3448
  text: typeof text;
3436
3449
  string: typeof text;
3437
- citext(this: ColumnTypesBase, min: number, max: number): CitextColumn;
3438
- bytea(this: ColumnTypesBase): ByteaColumn;
3439
- date(this: ColumnTypesBase): DateColumn;
3440
- timestampWithoutTimeZone<Precision_2 extends number>(this: ColumnTypesBase, precision?: Precision_2 | undefined): TimestampColumn<Precision_2>;
3441
- timestamp<Precision_3 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_3 | undefined): TimestampTzColumn<number>;
3442
- time<Precision_4 extends number | undefined = undefined>(this: ColumnTypesBase, precision?: Precision_4 | undefined): TimeColumn<Precision_4>;
3443
- interval<Fields extends string | undefined = undefined, Precision_5 extends number | undefined = undefined>(this: ColumnTypesBase, fields?: Fields | undefined, precision?: Precision_5 | undefined): IntervalColumn<Fields, Precision_5>;
3444
- boolean(this: ColumnTypesBase): BooleanColumn;
3445
- enum<U extends string, T_2 extends [U, ...U[]]>(this: ColumnTypesBase, dataType: string, type: T_2): EnumColumn<U, T_2>;
3446
- point(this: ColumnTypesBase): PointColumn;
3447
- line(this: ColumnTypesBase): LineColumn;
3448
- lseg(this: ColumnTypesBase): LsegColumn;
3449
- box(this: ColumnTypesBase): BoxColumn;
3450
- path(this: ColumnTypesBase): PathColumn;
3451
- polygon(this: ColumnTypesBase): PolygonColumn;
3452
- circle(this: ColumnTypesBase): CircleColumn;
3453
- cidr(this: ColumnTypesBase): CidrColumn;
3454
- inet(this: ColumnTypesBase): InetColumn;
3455
- macaddr(this: ColumnTypesBase): MacAddrColumn;
3456
- macaddr8(this: ColumnTypesBase): MacAddr8Column;
3457
- bit<Length extends number>(this: ColumnTypesBase, length: Length): BitColumn<Length>;
3458
- bitVarying<Length_1 extends number | undefined = undefined>(this: ColumnTypesBase, length?: Length_1 | undefined): BitVaryingColumn<Length_1>;
3459
- tsvector(this: ColumnTypesBase): TsVectorColumn;
3460
- tsquery(this: ColumnTypesBase): TsQueryColumn;
3461
- uuid(this: ColumnTypesBase): UUIDColumn;
3462
- xml(this: ColumnTypesBase): XMLColumn;
3463
- json<Type extends JSONTypeAny>(this: ColumnTypesBase, schemaOrFn: Type | ((j: JSONTypes) => Type)): JSONColumn<Type>;
3464
- jsonText(this: ColumnTypesBase): JSONTextColumn;
3465
- array<Item extends ColumnType<unknown, orchid_core.BaseOperators, unknown>>(this: ColumnTypesBase, item: Item): ArrayColumn<Item>;
3466
- type(this: ColumnTypesBase, dataType: string): CustomTypeColumn;
3467
- domain(this: ColumnTypesBase, dataType: string): DomainColumn;
3450
+ citext(min: number, max: number): CitextColumn;
3451
+ bytea(): ByteaColumn;
3452
+ date(): DateColumn;
3453
+ timestampWithoutTimeZone<Precision_2 extends number>(precision?: Precision_2 | undefined): TimestampColumn<Precision_2>;
3454
+ timestamp<Precision_3 extends number | undefined = undefined>(precision?: Precision_3 | undefined): TimestampTzColumn<number>;
3455
+ time<Precision_4 extends number | undefined = undefined>(precision?: Precision_4 | undefined): TimeColumn<Precision_4>;
3456
+ interval<Fields extends string | undefined = undefined, Precision_5 extends number | undefined = undefined>(fields?: Fields | undefined, precision?: Precision_5 | undefined): IntervalColumn<Fields, Precision_5>;
3457
+ boolean(): BooleanColumn;
3458
+ enum<U extends string, T_2 extends [U, ...U[]]>(dataType: string, type: T_2): EnumColumn<U, T_2>;
3459
+ point(): PointColumn;
3460
+ line(): LineColumn;
3461
+ lseg(): LsegColumn;
3462
+ box(): BoxColumn;
3463
+ path(): PathColumn;
3464
+ polygon(): PolygonColumn;
3465
+ circle(): CircleColumn;
3466
+ cidr(): CidrColumn;
3467
+ inet(): InetColumn;
3468
+ macaddr(): MacAddrColumn;
3469
+ macaddr8(): MacAddr8Column;
3470
+ bit<Length extends number>(length: Length): BitColumn<Length>;
3471
+ bitVarying<Length_1 extends number | undefined = undefined>(length?: Length_1 | undefined): BitVaryingColumn<Length_1>;
3472
+ tsvector(): TsVectorColumn;
3473
+ tsquery(): TsQueryColumn;
3474
+ uuid(): UUIDColumn;
3475
+ xml(): XMLColumn;
3476
+ json<Type extends JSONTypeAny>(schemaOrFn: Type | ((j: JSONTypes) => Type)): JSONColumn<Type>;
3477
+ jsonText(): JSONTextColumn;
3478
+ array<Item extends ColumnType<unknown, orchid_core.BaseOperators, unknown>>(item: Item): ArrayColumn<Item>;
3479
+ type(dataType: string): CustomTypeColumn;
3480
+ domain(dataType: string): DomainColumn;
3468
3481
  primaryKey(columns: string[], options?: {
3469
3482
  name?: string;
3470
3483
  }): {};