pqb 0.70.0 → 0.71.1

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.
@@ -668,7 +668,7 @@ interface ColumnSchemaGetterTableClass$1 {
668
668
  }
669
669
  interface ColumnTypeSchemaArg$1 {
670
670
  __schemaType: unknown;
671
- nullable<T extends Column$1.Pick.ForNullable>(this: T): Column$1.Modifiers.Nullable<T, unknown, unknown, unknown>;
671
+ nullable: unknown;
672
672
  encode: unknown;
673
673
  parse: unknown;
674
674
  parseNull: unknown;
@@ -737,7 +737,7 @@ declare namespace TableData$1 {
737
737
  name?: string;
738
738
  }
739
739
  export interface ColumnIndex {
740
- options: Index.ColumnArg & Index.Options;
740
+ options: Index.ColumnOptionsData;
741
741
  }
742
742
  export interface ColumnExclude extends ColumnIndex {
743
743
  with: string;
@@ -788,7 +788,11 @@ declare namespace TableData$1 {
788
788
  order?: string;
789
789
  weight?: SearchWeight$1;
790
790
  }
791
- export interface UniqueOptionsArg<Name extends string = string> {
791
+ /**
792
+ * Controls when Postgres checks a unique constraint.
793
+ */
794
+ export type UniqueDeferrable = false | 'immediate' | 'deferred';
795
+ export interface BaseUniqueOptionsArg<Name extends string = string> {
792
796
  name?: Name;
793
797
  nullsNotDistinct?: boolean;
794
798
  using?: string;
@@ -798,23 +802,45 @@ declare namespace TableData$1 {
798
802
  where?: string;
799
803
  dropMode?: DropMode;
800
804
  }
801
- export interface OptionsArg extends UniqueOptionsArg {
805
+ export interface UniqueOptionsArg<Name extends string = string> extends BaseUniqueOptionsArg<Name> {
806
+ /**
807
+ * Makes this unique definition a deferrable Postgres constraint.
808
+ */
809
+ deferrable?: UniqueDeferrable;
810
+ }
811
+ export interface NonUniqueIndexOptionsArg<Name extends string = string> extends BaseUniqueOptionsArg<Name> {
812
+ unique?: false;
813
+ deferrable?: never;
814
+ }
815
+ export interface UniqueIndexOptionsArg<Name extends string = string> extends UniqueOptionsArg<Name> {
816
+ unique: true;
817
+ }
818
+ export type OptionsArg<Name extends string = string> = NonUniqueIndexOptionsArg<Name> | UniqueIndexOptionsArg<Name>;
819
+ export type TsVectorArg = OptionsArg & TsVectorOptions;
820
+ export interface Options extends UniqueOptionsArg, TsVectorOptions {
802
821
  unique?: boolean;
803
822
  }
804
- export interface TsVectorArg extends OptionsArg, TsVectorOptions {}
805
- export type Options = TsVectorArg;
806
823
  export interface UniqueColumnArg<Name extends string = string> extends ColumnOptions, UniqueOptionsArg<Name> {
807
824
  expression?: string;
808
825
  }
809
- export interface ColumnArg extends UniqueColumnArg {
810
- unique?: boolean;
826
+ export interface NonUniqueColumnArg<Name extends string = string> extends ColumnOptions, BaseUniqueOptionsArg<Name> {
827
+ expression?: string;
828
+ unique?: false;
829
+ deferrable?: never;
811
830
  }
831
+ export interface UniqueIndexColumnArg<Name extends string = string> extends UniqueColumnArg<Name> {
832
+ unique: true;
833
+ }
834
+ export interface ColumnOptionsData extends ColumnOptions, Options {
835
+ expression?: string;
836
+ }
837
+ export type ColumnArg<Name extends string = string> = NonUniqueColumnArg<Name> | UniqueIndexColumnArg<Name>;
812
838
  interface TsVectorOptions {
813
839
  language?: string;
814
840
  languageColumn?: string;
815
841
  tsVector?: boolean;
816
842
  }
817
- export interface TsVectorColumnArg extends ColumnArg, TsVectorOptions {}
843
+ export type TsVectorColumnArg = ColumnArg & TsVectorOptions;
818
844
  export interface ExpressionOptions extends ColumnOptions {
819
845
  expression: string;
820
846
  }
@@ -943,7 +969,7 @@ interface NumberColumnData$1 extends BaseNumberData$1, Column$1.Data {
943
969
  identity?: TableData$1.Identity;
944
970
  }
945
971
  interface SerialColumnData$1 extends NumberColumnData$1 {
946
- default: Expression$1;
972
+ default: true;
947
973
  }
948
974
  declare abstract class NumberBaseColumn<Schema extends ColumnSchemaConfig$1, SchemaType extends Schema['__schemaType']> extends Column$1 {
949
975
  __schema: Schema;
@@ -988,27 +1014,26 @@ declare class DecimalColumn$1<Schema extends ColumnSchemaConfig$1> extends Numbe
988
1014
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
989
1015
  toSQL(): string;
990
1016
  }
991
- type IdentityColumn<T extends Column$1.Pick.Data> = Column$1.Modifiers.Default<T, Expression$1>;
992
1017
  declare class SmallIntColumn$1<Schema extends ColumnSchemaConfig$1> extends IntegerBaseColumn<Schema> {
993
1018
  dataType: "int2";
994
1019
  querySchema: ReturnType<Schema['int']>;
995
1020
  constructor(schema: Schema);
996
1021
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
997
- identity<T extends Column$1.Pick.Data>(this: T, options?: TableData$1.Identity): IdentityColumn<T>;
1022
+ identity<T extends Column$1.Pick.Data>(this: T, options?: TableData$1.Identity): Column$1.Modifiers.HasDefault<T>;
998
1023
  }
999
1024
  declare class IntegerColumn$1<Schema extends ColumnSchemaConfig$1> extends IntegerBaseColumn<Schema> {
1000
1025
  dataType: "int4";
1001
1026
  querySchema: ReturnType<Schema['int']>;
1002
1027
  constructor(schema: Schema);
1003
1028
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
1004
- identity<T extends Column$1.Pick.Data>(this: T, options?: TableData$1.Identity): IdentityColumn<T>;
1029
+ identity<T extends Column$1.Pick.Data>(this: T, options?: TableData$1.Identity): Column$1.Modifiers.HasDefault<T>;
1005
1030
  }
1006
1031
  declare class BigIntColumn$1<Schema extends ColumnSchemaConfig$1> extends NumberAsStringBaseColumn<Schema, string | number | bigint> {
1007
1032
  dataType: "int8";
1008
1033
  querySchema: ReturnType<Schema['stringSchema']>;
1009
1034
  constructor(schema: Schema);
1010
1035
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
1011
- identity<T extends Column$1.Pick.Data>(this: T, options?: TableData$1.Identity): IdentityColumn<T>;
1036
+ identity<T extends Column$1.Pick.Data>(this: T, options?: TableData$1.Identity): Column$1.Modifiers.HasDefault<T>;
1012
1037
  }
1013
1038
  declare class RealColumn$1<Schema extends ColumnSchemaConfig$1> extends NumberBaseColumn<Schema, ReturnType<Schema['number']>> {
1014
1039
  dataType: "float4";
@@ -1203,6 +1228,7 @@ declare class JSONTextColumn$1<T, Schema extends ColumnTypeSchemaArg$1, InputSch
1203
1228
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
1204
1229
  }
1205
1230
  interface DefaultSchemaConfig$1 extends ColumnSchemaConfig$1<Column$1> {
1231
+ nullable<T extends Column$1.Pick.ForNullable>(this: T): Column$1.Modifiers.Nullable<T>;
1206
1232
  parse<T extends Column$1.Pick.ForParse, Output>(this: T, fn: (input: T['__type']) => Output): Column$1.Modifiers.Parse<T, unknown, Output>;
1207
1233
  parseNull<T extends Column$1.Pick.ForParseNull, Output>(this: T, fn: () => Output): Column$1.Modifiers.ParseNull<T, unknown, Output>;
1208
1234
  encode<T extends Column$1.Pick.Type, Input>(this: T, fn: (input: Input) => unknown): Column$1.Modifiers.Encode<T, unknown, Input>;
@@ -1599,7 +1625,7 @@ declare class UUIDColumn$1<Schema extends ColumnSchemaConfig$1> extends Column$1
1599
1625
  T & {
1600
1626
  data: {
1601
1627
  primaryKey: Name;
1602
- default: RawSqlBase$1;
1628
+ default: true;
1603
1629
  };
1604
1630
  };
1605
1631
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
@@ -1651,8 +1677,8 @@ declare class BooleanColumn$1<Schema extends ColumnSchemaConfig$1> extends Colum
1651
1677
  toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
1652
1678
  }
1653
1679
  interface Timestamps$1<T extends Column$1.Pick.Data> {
1654
- createdAt: Column$1.Modifiers.Default<T, RawSqlBase$1>;
1655
- updatedAt: Column$1.Modifiers.Default<T, RawSqlBase$1>;
1680
+ createdAt: Column$1.Modifiers.HasDefault<T>;
1681
+ updatedAt: Column$1.Modifiers.HasDefault<T>;
1656
1682
  }
1657
1683
  interface TimestampHelpers {
1658
1684
  /**
@@ -1734,7 +1760,7 @@ interface DefaultColumnTypes$1<SchemaConfig extends ColumnSchemaConfig$1> extend
1734
1760
  decimal: SchemaConfig['decimal'];
1735
1761
  real: SchemaConfig['real'];
1736
1762
  doublePrecision: SchemaConfig['doublePrecision'];
1737
- identity(options?: TableData$1.Identity): IdentityColumn<ReturnType<SchemaConfig['integer']>>;
1763
+ identity(options?: TableData$1.Identity): Column$1.Modifiers.HasDefault<ReturnType<SchemaConfig['integer']>>;
1738
1764
  smallSerial: SchemaConfig['smallSerial'];
1739
1765
  serial: SchemaConfig['serial'];
1740
1766
  bigSerial: SchemaConfig['bigSerial'];
@@ -7247,7 +7273,8 @@ declare namespace Column$1 {
7247
7273
  unique: Name;
7248
7274
  };
7249
7275
  };
7250
- export type Nullable<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
7276
+ export type Nullable<T extends Column.Pick.ForNullable> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends '__queryType' ? T['__queryType'] | null : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
7277
+ export type NullableWithSchema<T extends Column.Pick.ForNullable, InputSchema, OutputSchema, QuerySchema> = { [K in keyof T]: K extends '__type' ? T['__type'] | null : K extends '__inputType' ? T['__inputType'] | null : K extends 'inputSchema' ? InputSchema : K extends '__outputType' ? T['__outputType'] | (unknown extends T['__nullType'] ? null : T['__nullType']) : K extends 'outputSchema' ? OutputSchema : K extends '__queryType' ? T['__queryType'] | null : K extends 'querySchema' ? QuerySchema : K extends 'data' ? T['data'] & DataNullable : K extends 'operators' ? { [K in keyof T['operators']]: K extends 'equals' | 'not' | 'isDistinctFrom' | 'isNotDistinctFrom' ? Operator<T['__queryType'] | null, T> : T['operators'][K] } : T[K] };
7251
7278
  export type QueryColumnToNullable<C> = { [K in keyof C]: K extends '__outputType' | '__queryType' ? C[K] | null : C[K] };
7252
7279
  export type QueryColumnToOptional<C> = { [K in keyof C]: K extends '__outputType' ? C[K] | undefined : C[K] };
7253
7280
  interface DataNullable {
@@ -7263,8 +7290,7 @@ declare namespace Column$1 {
7263
7290
  export type Encode<T, InputSchema, Input> = { [K in keyof T]: K extends '__inputType' ? Input : K extends 'inputSchema' ? InputSchema : T[K] };
7264
7291
  export type Parse<T extends Pick.ForParse, OutputSchema, Output> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? (Output extends null ? never : Output) | (unknown extends T['__nullType'] ? null : T['__nullType']) : Output : K extends 'outputSchema' ? null extends T['__type'] ? OutputSchema | T['nullSchema'] : OutputSchema : T[K] };
7265
7292
  export type ParseNull<T extends Column.Pick.ForParseNull, NullSchema, NullType> = { [K in keyof T]: K extends '__outputType' ? null extends T['__type'] ? Exclude<T['__outputType'], null> | NullType : T['__outputType'] : K extends '__nullType' ? NullType : K extends 'outputSchema' ? null extends T['__type'] ? T['outputSchema'] | NullSchema : T['outputSchema'] : K extends 'nullSchema' ? NullSchema : T[K] };
7266
- type DefaultData<T extends Column.Data, Value> = { [K in keyof T]: K extends 'default' ? Value extends null ? never : Value : K extends 'optional' ? true : T[K] };
7267
- export type Default<T extends Column.Pick.Data, Value> = { [K in keyof T]: K extends 'data' ? DefaultData<T['data'], Value> : T[K] };
7293
+ export type HasDefault<T extends Column.Pick.Data> = T & Column.Data.Default;
7268
7294
  type DefaultSelectData<T extends Column.Data, Value> = { [K in keyof T]: K extends 'explicitSelect' ? Value extends true ? false : true : T[K] };
7269
7295
  export type DefaultSelect<T extends Column.Pick.Data, Value extends boolean> = { [K in keyof T]: K extends 'data' ? DefaultSelectData<T['data'], Value> : T[K] };
7270
7296
  export interface IsAppReadOnly {
@@ -7364,6 +7390,7 @@ declare namespace Column$1 {
7364
7390
  interface TableParamInstance {
7365
7391
  schema?: string;
7366
7392
  table: string;
7393
+ nameInDb?: string;
7367
7394
  columns: PickQueryShape$1;
7368
7395
  }
7369
7396
  interface TableParam {
@@ -7455,6 +7482,12 @@ declare namespace Column$1 {
7455
7482
  skipValueToArray?: boolean;
7456
7483
  }
7457
7484
  export namespace Data {
7485
+ interface Default {
7486
+ data: {
7487
+ default: true;
7488
+ optional: true;
7489
+ };
7490
+ }
7458
7491
  interface Check {
7459
7492
  sql: RawSqlBase$1;
7460
7493
  name?: string;
@@ -7525,13 +7558,13 @@ declare abstract class Column$1 {
7525
7558
  *
7526
7559
  * @param value - default value or a function returning a value
7527
7560
  */
7528
- default<T extends Column.Pick.DataAndInputType, Value extends T['__inputType'] | null | RawSqlBase$1 | (() => T['__inputType'])>(this: T, value: Value): Column.Modifiers.Default<T, Value>;
7561
+ default<T extends Column.Pick.DataAndInputType, Value extends T['__inputType'] | null | RawSqlBase$1 | (() => T['__inputType'])>(this: T, value: Value): Column.Modifiers.HasDefault<T>;
7529
7562
  /**
7530
7563
  * Use `hasDefault` to let the column be omitted when creating records.
7531
7564
  *
7532
7565
  * It's better to use {@link default} instead so the value is explicit and serves as a hint.
7533
7566
  */
7534
- hasDefault<T extends Column.Pick.Data>(this: T): Column.Modifiers.Default<T, RawSqlBase$1>;
7567
+ hasDefault<T extends Column.Pick.Data>(this: T): Column.Modifiers.HasDefault<T>;
7535
7568
  /**
7536
7569
  * Set a database-level validation check to a column. `check` accepts a raw SQL.
7537
7570
  *
@@ -8224,7 +8257,7 @@ declare abstract class Column$1 {
8224
8257
  data: Column['data'];
8225
8258
  dataType: string;
8226
8259
  }>(this: T, ...args: [options?: TableData$1.Index.TsVectorColumnArg]): T;
8227
- unique<T extends Column.Pick.Data, const Options extends TableData$1.Index.ColumnArg>(this: T, ...args: [options?: Options]): T & Column.Modifiers.IsUnique<Options['name'] & string>;
8260
+ unique<T extends Column.Pick.Data, const Options extends TableData$1.Index.UniqueColumnArg>(this: T, ...args: [options?: Options]): T & Column.Modifiers.IsUnique<Options['name'] & string>;
8228
8261
  /**
8229
8262
  * Add [EXCLUDE constraint](https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-EXCLUDE) to the column.
8230
8263
  *
@@ -8347,6 +8380,7 @@ interface QueryData$1 extends QueryDataAliases, PickQueryDataParsers, HasHookSel
8347
8380
  type: QueryType;
8348
8381
  adapter: Adapter$1;
8349
8382
  selectShape: ColumnsShape$1;
8383
+ nameInDb?: string;
8350
8384
  handleResult: HandleResult;
8351
8385
  catch?: boolean;
8352
8386
  returnType: QueryReturnType$1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pqb",
3
- "version": "0.70.0",
3
+ "version": "0.71.1",
4
4
  "description": "Postgres query builder",
5
5
  "keywords": [
6
6
  "pg",