pqb 0.71.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.
- package/dist/index.d.ts +35 -9
- package/dist/index.js +4 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +35 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -714,7 +714,7 @@ declare namespace TableData {
|
|
|
714
714
|
name?: string;
|
|
715
715
|
}
|
|
716
716
|
export interface ColumnIndex {
|
|
717
|
-
options: Index.
|
|
717
|
+
options: Index.ColumnOptionsData;
|
|
718
718
|
}
|
|
719
719
|
export interface ColumnExclude extends ColumnIndex {
|
|
720
720
|
with: string;
|
|
@@ -765,7 +765,11 @@ declare namespace TableData {
|
|
|
765
765
|
order?: string;
|
|
766
766
|
weight?: SearchWeight;
|
|
767
767
|
}
|
|
768
|
-
|
|
768
|
+
/**
|
|
769
|
+
* Controls when Postgres checks a unique constraint.
|
|
770
|
+
*/
|
|
771
|
+
export type UniqueDeferrable = false | 'immediate' | 'deferred';
|
|
772
|
+
export interface BaseUniqueOptionsArg<Name extends string = string> {
|
|
769
773
|
name?: Name;
|
|
770
774
|
nullsNotDistinct?: boolean;
|
|
771
775
|
using?: string;
|
|
@@ -775,23 +779,45 @@ declare namespace TableData {
|
|
|
775
779
|
where?: string;
|
|
776
780
|
dropMode?: DropMode;
|
|
777
781
|
}
|
|
778
|
-
export interface
|
|
782
|
+
export interface UniqueOptionsArg<Name extends string = string> extends BaseUniqueOptionsArg<Name> {
|
|
783
|
+
/**
|
|
784
|
+
* Makes this unique definition a deferrable Postgres constraint.
|
|
785
|
+
*/
|
|
786
|
+
deferrable?: UniqueDeferrable;
|
|
787
|
+
}
|
|
788
|
+
export interface NonUniqueIndexOptionsArg<Name extends string = string> extends BaseUniqueOptionsArg<Name> {
|
|
789
|
+
unique?: false;
|
|
790
|
+
deferrable?: never;
|
|
791
|
+
}
|
|
792
|
+
export interface UniqueIndexOptionsArg<Name extends string = string> extends UniqueOptionsArg<Name> {
|
|
793
|
+
unique: true;
|
|
794
|
+
}
|
|
795
|
+
export type OptionsArg<Name extends string = string> = NonUniqueIndexOptionsArg<Name> | UniqueIndexOptionsArg<Name>;
|
|
796
|
+
export type TsVectorArg = OptionsArg & TsVectorOptions;
|
|
797
|
+
export interface Options extends UniqueOptionsArg, TsVectorOptions {
|
|
779
798
|
unique?: boolean;
|
|
780
799
|
}
|
|
781
|
-
export interface TsVectorArg extends OptionsArg, TsVectorOptions {}
|
|
782
|
-
export type Options = TsVectorArg;
|
|
783
800
|
export interface UniqueColumnArg<Name extends string = string> extends ColumnOptions, UniqueOptionsArg<Name> {
|
|
784
801
|
expression?: string;
|
|
785
802
|
}
|
|
786
|
-
export interface
|
|
787
|
-
|
|
803
|
+
export interface NonUniqueColumnArg<Name extends string = string> extends ColumnOptions, BaseUniqueOptionsArg<Name> {
|
|
804
|
+
expression?: string;
|
|
805
|
+
unique?: false;
|
|
806
|
+
deferrable?: never;
|
|
807
|
+
}
|
|
808
|
+
export interface UniqueIndexColumnArg<Name extends string = string> extends UniqueColumnArg<Name> {
|
|
809
|
+
unique: true;
|
|
810
|
+
}
|
|
811
|
+
export interface ColumnOptionsData extends ColumnOptions, Options {
|
|
812
|
+
expression?: string;
|
|
788
813
|
}
|
|
814
|
+
export type ColumnArg<Name extends string = string> = NonUniqueColumnArg<Name> | UniqueIndexColumnArg<Name>;
|
|
789
815
|
interface TsVectorOptions {
|
|
790
816
|
language?: string;
|
|
791
817
|
languageColumn?: string;
|
|
792
818
|
tsVector?: boolean;
|
|
793
819
|
}
|
|
794
|
-
export
|
|
820
|
+
export type TsVectorColumnArg = ColumnArg & TsVectorOptions;
|
|
795
821
|
export interface ExpressionOptions extends ColumnOptions {
|
|
796
822
|
expression: string;
|
|
797
823
|
}
|
|
@@ -7597,7 +7623,7 @@ declare abstract class Column {
|
|
|
7597
7623
|
data: Column['data'];
|
|
7598
7624
|
dataType: string;
|
|
7599
7625
|
}>(this: T, ...args: [options?: TableData.Index.TsVectorColumnArg]): T;
|
|
7600
|
-
unique<T extends Column.Pick.Data, const Options extends TableData.Index.
|
|
7626
|
+
unique<T extends Column.Pick.Data, const Options extends TableData.Index.UniqueColumnArg>(this: T, ...args: [options?: Options]): T & Column.Modifiers.IsUnique<Options['name'] & string>;
|
|
7601
7627
|
/**
|
|
7602
7628
|
* Add [EXCLUDE constraint](https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-EXCLUDE) to the column.
|
|
7603
7629
|
*
|
package/dist/index.js
CHANGED
|
@@ -1436,6 +1436,7 @@ const indexInnerToCode = (index, t) => {
|
|
|
1436
1436
|
"name",
|
|
1437
1437
|
"using",
|
|
1438
1438
|
"nullsNotDistinct",
|
|
1439
|
+
"deferrable",
|
|
1439
1440
|
"include",
|
|
1440
1441
|
"with",
|
|
1441
1442
|
"tablespace",
|
|
@@ -1617,6 +1618,7 @@ const columnIndexesToCode = (items) => {
|
|
|
1617
1618
|
options.using && `using: ${singleQuote(options.using)},`,
|
|
1618
1619
|
options.include && `include: ${typeof options.include === "string" ? singleQuote(options.include) : `[${options.include.map(singleQuote).join(", ")}]`},`,
|
|
1619
1620
|
options.nullsNotDistinct && `nullsNotDistinct: true,`,
|
|
1621
|
+
options.deferrable && `deferrable: ${singleQuote(options.deferrable)},`,
|
|
1620
1622
|
options.with && `with: ${singleQuote(options.with)},`,
|
|
1621
1623
|
options.tablespace && `tablespace: ${singleQuote(options.tablespace)},`,
|
|
1622
1624
|
options.where && `where: ${singleQuote(options.where)},`
|
|
@@ -5619,20 +5621,7 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery, shape, whereExists,
|
|
|
5619
5621
|
const args0 = args.length ? args[0] : returnArg;
|
|
5620
5622
|
if (typeof args0 === "function") {
|
|
5621
5623
|
let q = first;
|
|
5622
|
-
if (q.joinQueryAfterCallback)
|
|
5623
|
-
let base = q.baseQuery;
|
|
5624
|
-
if (q.q.as) base = base.as(q.q.as);
|
|
5625
|
-
const { q: query } = q.joinQueryAfterCallback(base, joinTo);
|
|
5626
|
-
if (query.and || query.or || query.scopes) {
|
|
5627
|
-
q = _clone(q);
|
|
5628
|
-
if (query.and) pushQueryArrayImmutable(q, "and", query.and);
|
|
5629
|
-
if (query.or) pushQueryArrayImmutable(q, "or", query.or);
|
|
5630
|
-
if (query.scopes) q.q.scopes = {
|
|
5631
|
-
...q.q.scopes,
|
|
5632
|
-
...query.scopes
|
|
5633
|
-
};
|
|
5634
|
-
}
|
|
5635
|
-
}
|
|
5624
|
+
if (q.joinQueryAfterCallback) q = q.joinQueryAfterCallback(q, joinTo);
|
|
5636
5625
|
const joinedShapes = {
|
|
5637
5626
|
...joinTo.q.joinedShapes,
|
|
5638
5627
|
[joinTo.q.as || joinTo.table]: joinTo.shape
|
|
@@ -10969,6 +10958,7 @@ const processNestedSelectPathEntry = (batches, path, thisKey, thisReturnType, i,
|
|
|
10969
10958
|
key: thisKey
|
|
10970
10959
|
});
|
|
10971
10960
|
else {
|
|
10961
|
+
if (!data) return;
|
|
10972
10962
|
const { key, returnType } = path[++i];
|
|
10973
10963
|
if (!thisReturnType || thisReturnType === "all") for (const row of data) processNestedSelectPathEntry(batches, path, key, returnType, i, last, row);
|
|
10974
10964
|
else processNestedSelectPathEntry(batches, path, key, returnType, i, last, data);
|