pqb 0.9.13 → 0.9.15
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/.turbo/turbo-test:ci.log +70 -0
- package/CHANGELOG.md +12 -0
- package/coverage/coverage-summary.json +97 -0
- package/dist/index.d.ts +647 -648
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/{columnSchema → columns}/array.test.ts +0 -0
- package/src/{columnSchema → columns}/array.ts +1 -1
- package/src/{columnSchema → columns}/boolean.test.ts +0 -0
- package/src/{columnSchema → columns}/boolean.ts +1 -1
- package/src/{columnSchema → columns}/code.test.ts +0 -0
- package/src/{columnSchema → columns}/code.ts +0 -0
- package/src/{columnSchema → columns}/columnType.test.ts +1 -1
- package/src/{columnSchema → columns}/columnType.ts +7 -6
- package/src/{columnSchema → columns}/columnTypes.ts +0 -0
- package/src/{columnSchema → columns}/columnsByType.ts +0 -0
- package/src/{columnSchema → columns}/columnsSchema.ts +1 -1
- package/src/{columnSchema → columns}/commonMethods.ts +0 -0
- package/src/{columnSchema → columns}/dateTime.test.ts +0 -0
- package/src/{columnSchema → columns}/dateTime.ts +1 -1
- package/src/{columnSchema → columns}/enum.test.ts +0 -0
- package/src/{columnSchema → columns}/enum.ts +4 -3
- package/src/{columnSchema → columns}/index.ts +0 -0
- package/src/{columnSchema → columns}/json/array.test.ts +0 -0
- package/src/{columnSchema → columns}/json/array.ts +0 -0
- package/src/{columnSchema → columns}/json/discriminatedUnion.test.ts +0 -0
- package/src/{columnSchema → columns}/json/discriminatedUnion.ts +0 -0
- package/src/{columnSchema → columns}/json/enum.test.ts +0 -0
- package/src/{columnSchema → columns}/json/enum.ts +0 -0
- package/src/{columnSchema → columns}/json/index.ts +0 -0
- package/src/{columnSchema → columns}/json/instanceOf.test.ts +0 -0
- package/src/{columnSchema → columns}/json/instanceOf.ts +0 -0
- package/src/{columnSchema → columns}/json/intersection.test.ts +0 -0
- package/src/{columnSchema → columns}/json/intersection.ts +0 -0
- package/src/{columnSchema → columns}/json/lazy.test.ts +0 -0
- package/src/{columnSchema → columns}/json/lazy.ts +0 -0
- package/src/{columnSchema → columns}/json/literal.test.ts +0 -0
- package/src/{columnSchema → columns}/json/literal.ts +0 -0
- package/src/{columnSchema → columns}/json/map.test.ts +0 -0
- package/src/{columnSchema → columns}/json/map.ts +0 -0
- package/src/{columnSchema → columns}/json/nativeEnum.test.ts +0 -0
- package/src/{columnSchema → columns}/json/nativeEnum.ts +0 -0
- package/src/{columnSchema → columns}/json/nullable.test.ts +0 -0
- package/src/{columnSchema → columns}/json/nullable.ts +0 -0
- package/src/{columnSchema → columns}/json/nullish.test.ts +0 -0
- package/src/{columnSchema → columns}/json/nullish.ts +0 -0
- package/src/{columnSchema → columns}/json/object.test.ts +0 -0
- package/src/{columnSchema → columns}/json/object.ts +0 -0
- package/src/{columnSchema → columns}/json/optional.test.ts +0 -0
- package/src/{columnSchema → columns}/json/optional.ts +0 -0
- package/src/{columnSchema → columns}/json/record.test.ts +0 -0
- package/src/{columnSchema → columns}/json/record.ts +0 -0
- package/src/{columnSchema → columns}/json/scalarTypes.test.ts +0 -0
- package/src/{columnSchema → columns}/json/scalarTypes.ts +0 -0
- package/src/{columnSchema → columns}/json/set.test.ts +0 -0
- package/src/{columnSchema → columns}/json/set.ts +0 -0
- package/src/{columnSchema → columns}/json/tuple.test.ts +0 -0
- package/src/{columnSchema → columns}/json/tuple.ts +0 -0
- package/src/{columnSchema → columns}/json/typeBase.test.ts +0 -0
- package/src/{columnSchema → columns}/json/typeBase.ts +0 -0
- package/src/{columnSchema → columns}/json/union.test.ts +0 -0
- package/src/{columnSchema → columns}/json/union.ts +0 -0
- package/src/{columnSchema → columns}/json.test.ts +0 -0
- package/src/{columnSchema → columns}/json.ts +1 -1
- package/src/{columnSchema → columns}/number.test.ts +0 -0
- package/src/{columnSchema → columns}/number.ts +1 -1
- package/src/{columnsOperators.test.ts → columns/operators.test.ts} +1 -1
- package/src/{columnsOperators.ts → columns/operators.ts} +4 -4
- package/src/{columnSchema → columns}/string.test.ts +0 -0
- package/src/{columnSchema → columns}/string.ts +1 -1
- package/src/{columnSchema → columns}/timestamps.test.ts +0 -0
- package/src/{columnSchema → columns}/utils.ts +0 -0
- package/src/{columnSchema → columns}/virtual.ts +1 -1
- package/src/db.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/index.ts +2 -2
- package/src/query.ts +1 -1
- package/src/queryMethods/aggregate.ts +1 -1
- package/src/queryMethods/create.ts +1 -1
- package/src/queryMethods/join.ts +1 -1
- package/src/queryMethods/json.test.ts +1 -1
- package/src/queryMethods/json.ts +1 -1
- package/src/queryMethods/merge.test.ts +1 -1
- package/src/queryMethods/queryMethods.ts +1 -1
- package/src/queryMethods/raw.test.ts +1 -1
- package/src/queryMethods/raw.ts +1 -1
- package/src/queryMethods/select.test.ts +1 -1
- package/src/queryMethods/select.ts +1 -1
- package/src/queryMethods/update.ts +1 -1
- package/src/queryMethods/where.ts +1 -1
- package/src/queryMethods/window.ts +1 -1
- package/src/queryMethods/with.test.ts +1 -1
- package/src/queryMethods/with.ts +1 -1
- package/src/raw.ts +1 -1
- package/src/sql/data.ts +1 -1
- package/src/sql/having.ts +1 -1
- package/src/sql/types.ts +1 -1
- package/src/utils.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pqb",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.15",
|
|
4
4
|
"description": "Postgres query builder",
|
|
5
5
|
"homepage": "https://orchid-orm.netlify.app/guide/query-builder-setup.html",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"typescript": "^4.7.4"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"test": "jest",
|
|
59
|
+
"test": "jest --watch --verbose false",
|
|
60
|
+
"check": "jest",
|
|
60
61
|
"test:ci": "jest --coverage --coverageReporters json-summary",
|
|
61
62
|
"build": "rimraf ./dist/ && rollup -c --rollup.config"
|
|
62
63
|
}
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnData, ColumnType } from './columnType';
|
|
2
|
-
import { Operators } from '
|
|
2
|
+
import { Operators } from './operators';
|
|
3
3
|
import { assignMethodsToClass } from './utils';
|
|
4
4
|
import { arrayMethods } from './commonMethods';
|
|
5
5
|
import { addCode, Code, columnCode } from './code';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseOperators, Operator } from './operators';
|
|
2
2
|
import { JSONTypeAny } from './json';
|
|
3
3
|
import { ColumnsShape } from './columnsSchema';
|
|
4
4
|
import { raw, RawExpression } from '../raw';
|
|
@@ -17,9 +17,10 @@ export type NullableColumn<T extends ColumnType> = Omit<
|
|
|
17
17
|
type: T['type'] | null;
|
|
18
18
|
inputType: T['inputType'] | null;
|
|
19
19
|
isNullable: true;
|
|
20
|
-
operators:
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
operators: {
|
|
21
|
+
[K in keyof T['operators']]: K extends 'equals' | 'not'
|
|
22
|
+
? Operator<T['type'] | null>
|
|
23
|
+
: T['operators'][K];
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -178,7 +179,7 @@ export const instantiateColumn = (
|
|
|
178
179
|
|
|
179
180
|
export abstract class ColumnType<
|
|
180
181
|
Type = unknown,
|
|
181
|
-
Ops extends
|
|
182
|
+
Ops extends BaseOperators = BaseOperators,
|
|
182
183
|
InputType = Type,
|
|
183
184
|
> {
|
|
184
185
|
abstract dataType: string;
|
|
@@ -271,7 +272,7 @@ export abstract class ColumnType<
|
|
|
271
272
|
|
|
272
273
|
as<
|
|
273
274
|
T extends ColumnType,
|
|
274
|
-
C extends ColumnType<T['type'],
|
|
275
|
+
C extends ColumnType<T['type'], BaseOperators, T['inputType']>,
|
|
275
276
|
>(this: T, column: C): C {
|
|
276
277
|
return addColumnData(this, 'as', column) as unknown as C;
|
|
277
278
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnInput, ColumnOutput, ColumnType } from './columnType';
|
|
2
|
-
import { Operators } from '
|
|
2
|
+
import { Operators } from './operators';
|
|
3
3
|
import { SetOptional, SomeIsTrue, StringKey } from '../utils';
|
|
4
4
|
|
|
5
5
|
export type ColumnsShape = Record<string, ColumnType>;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnData, ColumnType } from './columnType';
|
|
2
|
-
import { Operators } from '
|
|
2
|
+
import { Operators } from './operators';
|
|
3
3
|
import { joinTruthy } from '../utils';
|
|
4
4
|
import { dateTypeMethods } from './commonMethods';
|
|
5
5
|
import { assignMethodsToClass } from './utils';
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ColumnType } from './columnType';
|
|
2
|
-
import { Operators } from '
|
|
2
|
+
import { Operators } from './operators';
|
|
3
3
|
import { Code, columnCode } from './code';
|
|
4
|
+
import { quoteFullColumn } from '../sql/common';
|
|
4
5
|
|
|
5
6
|
export class EnumColumn<
|
|
6
7
|
U extends string = string,
|
|
@@ -23,7 +24,7 @@ export class EnumColumn<
|
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
return this.enumName;
|
|
27
|
+
toSQL() {
|
|
28
|
+
return quoteFullColumn(this.enumName);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Query } from '
|
|
2
|
-
import { addValue } from '
|
|
3
|
-
import { getRaw, isRaw, RawExpression } from '
|
|
1
|
+
import { Query } from '../query';
|
|
2
|
+
import { addValue } from '../sql/common';
|
|
3
|
+
import { getRaw, isRaw, RawExpression } from '../raw';
|
|
4
4
|
|
|
5
5
|
type Fn<T> = (key: string, value: T, values: unknown[]) => string;
|
|
6
6
|
|
|
7
7
|
export type Operator<T> = Fn<T> & { type: T };
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
export type
|
|
10
|
+
export type BaseOperators = Record<string, Operator<any>>;
|
|
11
11
|
|
|
12
12
|
export const createOperator = <T>(fn: Fn<T>) => {
|
|
13
13
|
return Object.assign(fn, { type: undefined as unknown as T });
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnData, ColumnType } from './columnType';
|
|
2
|
-
import { Operators } from '
|
|
2
|
+
import { Operators } from './operators';
|
|
3
3
|
import { joinTruthy, singleQuote } from '../utils';
|
|
4
4
|
import { NumberBaseColumn } from './number';
|
|
5
5
|
import { assignMethodsToClass } from './utils';
|
|
File without changes
|
|
File without changes
|
package/src/db.ts
CHANGED
package/src/errors.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './columns';
|
|
2
2
|
export * from './sql';
|
|
3
3
|
export * from './adapter';
|
|
4
4
|
export * from './raw';
|
|
@@ -10,4 +10,4 @@ export * from './utils';
|
|
|
10
10
|
export * from './queryDataUtils';
|
|
11
11
|
export * from './errors';
|
|
12
12
|
export * from './relations';
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './columns/operators';
|
package/src/query.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { WhereArg } from './where';
|
|
|
20
20
|
import { parseResult, queryMethodByReturnType } from './then';
|
|
21
21
|
import { NotFoundError } from '../errors';
|
|
22
22
|
import { RawExpression } from '../raw';
|
|
23
|
-
import { VirtualColumn } from '../
|
|
23
|
+
import { VirtualColumn } from '../columns';
|
|
24
24
|
import { anyShape } from '../db';
|
|
25
25
|
|
|
26
26
|
export type CreateData<
|
package/src/queryMethods/join.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { RawExpression } from '../raw';
|
|
|
13
13
|
import { WhereQueryBuilder } from './where';
|
|
14
14
|
import { Relation, RelationsBase } from '../relations';
|
|
15
15
|
import { QueryData } from '../sql';
|
|
16
|
-
import { ColumnsShape } from '../
|
|
16
|
+
import { ColumnsShape } from '../columns';
|
|
17
17
|
import { StringKey } from '../utils';
|
|
18
18
|
|
|
19
19
|
type WithSelectable<
|
package/src/queryMethods/json.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
SetQueryReturnsValueOptional,
|
|
6
6
|
} from '../query';
|
|
7
7
|
import { pushQueryValue } from '../queryDataUtils';
|
|
8
|
-
import { ColumnType, StringColumn } from '../
|
|
8
|
+
import { ColumnType, StringColumn } from '../columns';
|
|
9
9
|
import { JsonItem } from '../sql';
|
|
10
10
|
import { raw } from '../raw';
|
|
11
11
|
import { StringKey } from '../utils';
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
User,
|
|
8
8
|
} from '../test-utils/test-utils';
|
|
9
9
|
import { QueryReturnType } from '../query';
|
|
10
|
-
import { IntegerColumn, TextColumn } from '../
|
|
10
|
+
import { IntegerColumn, TextColumn } from '../columns';
|
|
11
11
|
import { getValueKey } from './get';
|
|
12
12
|
import { logParamToLogObject } from './log';
|
|
13
13
|
import {
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from '../sql';
|
|
31
31
|
import { pushQueryArray, pushQueryValue } from '../queryDataUtils';
|
|
32
32
|
import { Then } from './then';
|
|
33
|
-
import { BooleanColumn } from '../
|
|
33
|
+
import { BooleanColumn } from '../columns';
|
|
34
34
|
import { Aggregate } from './aggregate';
|
|
35
35
|
import { addParserForSelectItem, Select } from './select';
|
|
36
36
|
import { From } from './from';
|
package/src/queryMethods/raw.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
UserRecord,
|
|
11
11
|
useTestDatabase,
|
|
12
12
|
} from '../test-utils/test-utils';
|
|
13
|
-
import { DateColumn } from '../
|
|
13
|
+
import { DateColumn } from '../columns';
|
|
14
14
|
|
|
15
15
|
const insertUserAndProfile = async () => {
|
|
16
16
|
const id = await User.get('id').create(userData);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ColumnsObject,
|
|
14
14
|
NullableColumn,
|
|
15
15
|
PluckResultColumnType,
|
|
16
|
-
} from '../
|
|
16
|
+
} from '../columns';
|
|
17
17
|
import { RawExpression } from '../raw';
|
|
18
18
|
import { pushQueryArray } from '../queryDataUtils';
|
|
19
19
|
import { parseRecord } from './then';
|
|
@@ -13,7 +13,7 @@ import { EmptyObject, MaybeArray, StringKey } from '../utils';
|
|
|
13
13
|
import { CreateData } from './create';
|
|
14
14
|
import { parseResult, queryMethodByReturnType } from './then';
|
|
15
15
|
import { UpdateQueryData } from '../sql';
|
|
16
|
-
import { ColumnsShape, VirtualColumn } from '../
|
|
16
|
+
import { ColumnsShape, VirtualColumn } from '../columns';
|
|
17
17
|
import { anyShape } from '../db';
|
|
18
18
|
|
|
19
19
|
export type UpdateData<T extends Query> = {
|
|
@@ -4,7 +4,7 @@ import { pushQueryArray, pushQueryValue } from '../queryDataUtils';
|
|
|
4
4
|
import { getClonedQueryData, MaybeArray } from '../utils';
|
|
5
5
|
import { JoinArgs, JoinCallback, JoinCallbackArg } from './join';
|
|
6
6
|
import { RelationsBase } from '../relations';
|
|
7
|
-
import { ColumnsShape } from '../
|
|
7
|
+
import { ColumnsShape } from '../columns';
|
|
8
8
|
import { RawExpression } from '../raw';
|
|
9
9
|
|
|
10
10
|
export type WhereArg<T extends QueryBase> =
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Query } from '../query';
|
|
2
|
-
import { ColumnType, IntegerColumn } from '../
|
|
2
|
+
import { ColumnType, IntegerColumn } from '../columns';
|
|
3
3
|
import { SelectAgg, WindowFunctionOptions } from './aggregate';
|
|
4
4
|
import { pushQueryValue } from '../queryDataUtils';
|
|
5
5
|
import { addParserToQuery } from './select';
|
package/src/queryMethods/with.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WithOptions } from '../sql';
|
|
2
|
-
import { ColumnShapeOutput, ColumnsShape, ColumnTypes } from '../
|
|
2
|
+
import { ColumnShapeOutput, ColumnsShape, ColumnTypes } from '../columns';
|
|
3
3
|
import { isRaw, RawExpression } from '../raw';
|
|
4
4
|
import { AddQueryWith, Query } from '../query';
|
|
5
5
|
import { Db } from '../db';
|
package/src/raw.ts
CHANGED
package/src/sql/data.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../queryMethods';
|
|
9
9
|
import { Adapter, QueryResult } from '../adapter';
|
|
10
10
|
import { RelationQueryData, relationQueryKey } from '../relations';
|
|
11
|
-
import { ColumnsShape } from '../
|
|
11
|
+
import { ColumnsShape } from '../columns';
|
|
12
12
|
import { toSqlCacheKey } from './toSql';
|
|
13
13
|
import {
|
|
14
14
|
HavingItem,
|
package/src/sql/having.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AggregateItemOptions, HavingItem } from './types';
|
|
2
2
|
import { getRaw, isRaw, RawExpression } from '../raw';
|
|
3
|
-
import { Operator } from '../
|
|
3
|
+
import { Operator } from '../columns/operators';
|
|
4
4
|
import { aggregateToSql } from './aggregate';
|
|
5
5
|
import { QueryBase } from '../query';
|
|
6
6
|
import { addValue, q } from './common';
|
package/src/sql/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Query, QueryBase, QueryWithTable, SelectableBase } from '../query';
|
|
2
2
|
import { RawExpression } from '../raw';
|
|
3
|
-
import { ColumnType } from '../
|
|
3
|
+
import { ColumnType } from '../columns';
|
|
4
4
|
import { RelationQuery } from '../relations';
|
|
5
5
|
import { Expression, MaybeArray } from '../utils';
|
|
6
6
|
import { QueryData, SelectQueryData } from './data';
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cloneQueryArrays, QueryData, toSqlCacheKey } from './sql';
|
|
2
2
|
import type { Query, Selectable } from './query';
|
|
3
|
-
import type { ColumnOutput, ColumnType } from './
|
|
3
|
+
import type { ColumnOutput, ColumnType } from './columns';
|
|
4
4
|
import type { RawExpression } from './raw';
|
|
5
5
|
export * from '../../common/utils';
|
|
6
6
|
|