pqb 0.38.5 → 0.38.6
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 +18 -11
- package/dist/index.js +34 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1095,9 +1095,9 @@ class NumberAsStringBaseColumn extends ColumnType {
|
|
|
1095
1095
|
this.operators = Operators.number;
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
1098
|
-
class DecimalColumn extends
|
|
1098
|
+
class DecimalColumn extends NumberAsStringBaseColumn {
|
|
1099
1099
|
constructor(schema, numericPrecision, numericScale) {
|
|
1100
|
-
super(schema
|
|
1100
|
+
super(schema);
|
|
1101
1101
|
this.operators = Operators.number;
|
|
1102
1102
|
this.dataType = "numeric";
|
|
1103
1103
|
this.data.numericPrecision = numericPrecision;
|
|
@@ -4569,25 +4569,29 @@ class SelectItemExpression extends Expression {
|
|
|
4569
4569
|
}
|
|
4570
4570
|
}
|
|
4571
4571
|
|
|
4572
|
-
const
|
|
4572
|
+
const _getSelectableColumn = (q, arg) => {
|
|
4573
4573
|
var _a, _b;
|
|
4574
|
+
let type = q.q.shape[arg];
|
|
4575
|
+
if (!type) {
|
|
4576
|
+
const index = arg.indexOf(".");
|
|
4577
|
+
if (index !== -1) {
|
|
4578
|
+
const table = arg.slice(0, index);
|
|
4579
|
+
const column = arg.slice(index + 1);
|
|
4580
|
+
if (table === (q.q.as || q.table)) {
|
|
4581
|
+
type = q.shape[column];
|
|
4582
|
+
} else {
|
|
4583
|
+
type = (_b = (_a = q.q.joinedShapes) == null ? void 0 : _a[table]) == null ? void 0 : _b[column];
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4587
|
+
return type;
|
|
4588
|
+
};
|
|
4589
|
+
const _get = (query, returnType, arg) => {
|
|
4574
4590
|
const q = query.q;
|
|
4575
4591
|
q.returnType = returnType;
|
|
4576
4592
|
let type;
|
|
4577
4593
|
if (typeof arg === "string") {
|
|
4578
|
-
type =
|
|
4579
|
-
if (!type) {
|
|
4580
|
-
const index = arg.indexOf(".");
|
|
4581
|
-
if (index !== -1) {
|
|
4582
|
-
const table = arg.slice(0, index);
|
|
4583
|
-
const column = arg.slice(index + 1);
|
|
4584
|
-
if (table === (q.as || query.table)) {
|
|
4585
|
-
type = q.shape[column];
|
|
4586
|
-
} else {
|
|
4587
|
-
type = (_b = (_a = q.joinedShapes) == null ? void 0 : _a[table]) == null ? void 0 : _b[column];
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
}
|
|
4594
|
+
type = _getSelectableColumn(query, arg);
|
|
4591
4595
|
q.getColumn = type;
|
|
4592
4596
|
const selected = setParserForSelectedString(
|
|
4593
4597
|
query,
|
|
@@ -6550,6 +6554,13 @@ const nullableInt = new IntegerColumn(defaultSchemaConfig);
|
|
|
6550
6554
|
nullableInt.parseItem = nullableInt.parseFn = (input) => input === null ? null : parseInt(input);
|
|
6551
6555
|
const nullableFloat = new RealColumn(defaultSchemaConfig);
|
|
6552
6556
|
nullableFloat.parseItem = nullableFloat.parseFn = (input) => input === null ? null : parseFloat(input);
|
|
6557
|
+
const stringAsNumber = new NumberAsStringBaseColumn(
|
|
6558
|
+
defaultSchemaConfig
|
|
6559
|
+
);
|
|
6560
|
+
const numericResultColumn = (q, arg) => {
|
|
6561
|
+
const type = typeof arg === "string" ? _getSelectableColumn(q, arg) : arg.result.value;
|
|
6562
|
+
return type instanceof NumberBaseColumn ? nullableFloat : stringAsNumber;
|
|
6563
|
+
};
|
|
6553
6564
|
class AggregateMethods {
|
|
6554
6565
|
/**
|
|
6555
6566
|
* Use `exists()` to check if there is at least one record-matching condition.
|
|
@@ -6620,7 +6631,7 @@ class AggregateMethods {
|
|
|
6620
6631
|
min(arg, options) {
|
|
6621
6632
|
return makeFnExpression(
|
|
6622
6633
|
this,
|
|
6623
|
-
|
|
6634
|
+
numericResultColumn(this, arg),
|
|
6624
6635
|
"min",
|
|
6625
6636
|
[arg],
|
|
6626
6637
|
options
|
|
@@ -6650,7 +6661,7 @@ class AggregateMethods {
|
|
|
6650
6661
|
max(arg, options) {
|
|
6651
6662
|
return makeFnExpression(
|
|
6652
6663
|
this,
|
|
6653
|
-
|
|
6664
|
+
numericResultColumn(this, arg),
|
|
6654
6665
|
"max",
|
|
6655
6666
|
[arg],
|
|
6656
6667
|
options
|
|
@@ -6679,7 +6690,7 @@ class AggregateMethods {
|
|
|
6679
6690
|
sum(arg, options) {
|
|
6680
6691
|
return makeFnExpression(
|
|
6681
6692
|
this,
|
|
6682
|
-
|
|
6693
|
+
numericResultColumn(this, arg),
|
|
6683
6694
|
"sum",
|
|
6684
6695
|
[arg],
|
|
6685
6696
|
options
|
|
@@ -6705,7 +6716,7 @@ class AggregateMethods {
|
|
|
6705
6716
|
avg(arg, options) {
|
|
6706
6717
|
return makeFnExpression(
|
|
6707
6718
|
this,
|
|
6708
|
-
|
|
6719
|
+
numericResultColumn(this, arg),
|
|
6709
6720
|
"avg",
|
|
6710
6721
|
[arg],
|
|
6711
6722
|
options
|
|
@@ -6734,7 +6745,7 @@ class AggregateMethods {
|
|
|
6734
6745
|
bitAnd(arg, options) {
|
|
6735
6746
|
return makeFnExpression(
|
|
6736
6747
|
this,
|
|
6737
|
-
|
|
6748
|
+
numericResultColumn(this, arg),
|
|
6738
6749
|
"bit_and",
|
|
6739
6750
|
[arg],
|
|
6740
6751
|
options
|
|
@@ -6760,7 +6771,7 @@ class AggregateMethods {
|
|
|
6760
6771
|
bitOr(arg, options) {
|
|
6761
6772
|
return makeFnExpression(
|
|
6762
6773
|
this,
|
|
6763
|
-
|
|
6774
|
+
numericResultColumn(this, arg),
|
|
6764
6775
|
"bit_or",
|
|
6765
6776
|
[arg],
|
|
6766
6777
|
options
|
|
@@ -12799,5 +12810,5 @@ function copyTableData(query, arg) {
|
|
|
12799
12810
|
return q;
|
|
12800
12811
|
}
|
|
12801
12812
|
|
|
12802
|
-
export { Adapter, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, ComputedColumn, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, 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, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql$1 as rollbackSql, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
12813
|
+
export { Adapter, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, ComputedColumn, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, XMLColumn, _getSelectableColumn, _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, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql$1 as rollbackSql, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
12803
12814
|
//# sourceMappingURL=index.mjs.map
|