pqb 0.4.7 → 0.4.8
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 +7 -1
- package/dist/index.esm.js +36 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +36 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/columnSchema/columnType.test.ts +220 -0
- package/src/columnSchema/columnType.ts +7 -0
- package/src/columnSchema/dateTime.ts +11 -0
- package/src/db.ts +4 -1
- package/src/queryMethods/create.test.ts +43 -0
- package/src/queryMethods/create.ts +27 -5
- package/src/queryMethods/update.test.ts +18 -0
- package/src/queryMethods/update.ts +11 -1
package/dist/index.d.ts
CHANGED
|
@@ -877,6 +877,7 @@ declare class UnhandledTypeError extends PormInternalError {
|
|
|
877
877
|
declare type DbTableOptions = {
|
|
878
878
|
schema?: string;
|
|
879
879
|
} & QueryLogOptions;
|
|
880
|
+
declare const anyShape: Record<string, ColumnType<unknown, Operators, unknown>>;
|
|
880
881
|
interface Db<Table extends string | undefined = undefined, Shape extends ColumnsShape = Record<string, never>, Relations extends Query['relations'] = Query['relations'], CT extends ColumnTypesBase = ColumnTypesBase> extends QueryMethods {
|
|
881
882
|
new (adapter: Adapter, queryBuilder: Db<Table, Shape, Relations, CT>, table?: Table, shape?: Shape, options?: DbTableOptions): this;
|
|
882
883
|
adapter: Adapter;
|
|
@@ -2346,6 +2347,7 @@ declare abstract class ColumnType<Type = unknown, Ops extends Operators = Operat
|
|
|
2346
2347
|
parse<T extends ColumnType, Output>(this: T, fn: (input: T['type']) => Output): Omit<T, 'type'> & {
|
|
2347
2348
|
type: Output;
|
|
2348
2349
|
};
|
|
2350
|
+
as<T extends ColumnType, C extends ColumnType<T['type'], Operators, T['inputType']>>(this: T, _: C): C;
|
|
2349
2351
|
toSQL(): string;
|
|
2350
2352
|
default<T extends ColumnType>(this: T, value: T['type'] | RawExpression): T & {
|
|
2351
2353
|
hasDefault: true;
|
|
@@ -3420,6 +3422,10 @@ declare abstract class DateBaseColumn extends ColumnType<string, typeof Operator
|
|
|
3420
3422
|
type: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | Date[];
|
|
3421
3423
|
};
|
|
3422
3424
|
};
|
|
3425
|
+
asNumber(): IntegerColumn;
|
|
3426
|
+
asDate<T extends ColumnType>(this: T): Omit<T, "type"> & {
|
|
3427
|
+
type: Date;
|
|
3428
|
+
};
|
|
3423
3429
|
}
|
|
3424
3430
|
declare class DateColumn extends DateBaseColumn {
|
|
3425
3431
|
dataType: "date";
|
|
@@ -4337,4 +4343,4 @@ declare const setQueryObjectValue: <T extends {
|
|
|
4337
4343
|
query: QueryData;
|
|
4338
4344
|
}>(q: T, object: string, key: string, value: unknown) => T;
|
|
4339
4345
|
|
|
4340
|
-
export { Adapter, AdapterOptions, AddQueryJoinedTable, AddQuerySelect, AddQueryWith, AfterCallback, Aggregate, Aggregate1ArgumentTypes, AggregateArg, AggregateItem, AggregateItemArg, AggregateItemOptions, AggregateOptions, AliasOrTable, AnyColumnType, AnyColumnTypeCreator, ArrayCardinality, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AssertArray, BaseNumberData, BaseRelation, BaseStringData, BeforeCallback, BelongsToNestedInsert, BelongsToNestedUpdate, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanExpression, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ClearStatement, CoalesceString, ColumnData, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnInput, ColumnNameOfModel, ColumnOperators, ColumnOutput, ColumnParser, ColumnShapeInput, ColumnShapeOutput, ColumnType, ColumnTypes, ColumnTypesBase, ColumnsObject, ColumnsParsers, ColumnsShape, CommonQueryData, Create, CreateData, CreateMethodsNames, DateBaseColumn, DateColumn, DateColumnData, DateTimeBaseClass, DateTimeColumnData, DateTimeWithTimeZoneBaseClass, Db, DbOptions, DbTableOptions, DecimalBaseColumn, DecimalColumn, DecimalColumnData, DeepPartial, DefaultSelectColumns, Delete, DeleteMethodsNames, DeleteQueryData, DoublePrecisionColumn, DropMode, EMPTY_OBJECT, EmptyObject, EnumColumn, EnumLike, Except, Expression, ExpressionOfType, ExpressionOutput, FilterTuple, For, ForeignKey, ForeignKeyModel, ForeignKeyModelWithColumns, ForeignKeyOptions, From, GetArg, HasAndBelongsToManyRelation, HasManyNestedInsert, HasManyNestedUpdate, HasManyRelation, HasOneNestedInsert, HasOneNestedUpdate, HasOneRelation, Having, HavingArg, HavingItem, IndexColumnOptions, IndexOptions, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsEqual, JSONAny, JSONArray, JSONBigInt, JSONBoolean, JSONColumn, JSONDate, JSONDiscriminatedObject, JSONDiscriminatedUnion, JSONEnum, JSONInstanceOf, JSONIntersection, JSONLazy, JSONLiteral, JSONMap, JSONNaN, JSONNativeEnum, JSONNever, JSONNotNullable, JSONNotNullish, JSONNull, JSONNullable, JSONNullish, JSONNumber, JSONObject, JSONObjectShape, JSONOptional, JSONRecord, JSONRecordKeyType, JSONRequired, JSONSet, JSONString, JSONTextColumn, JSONTuple, JSONTupleItems, JSONType, JSONTypeAny, JSONTypeData, JSONTypes, JSONUndefined, JSONUnion, JSONUnknown, JSONVoid, Join, JoinArgs, JoinCallback, JoinCallbackArg, JoinItem, JoinedTablesBase, Json, JsonItem, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MaybeArray, Merge, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NestedInsertItem, NestedInsertManyItems, NestedInsertOneItem, NestedUpdateItem, NestedUpdateManyItems, NestedUpdateOneItem, NotFoundError, NullableColumn, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, NumberExpression, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrderArg, OrderItem, OutputTypeOfTuple, OutputTypeOfTupleWithRest, OwnTypeProps, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, Primitive, Query, QueryArraysResult, QueryBase, QueryCallbacks, QueryData, QueryError, QueryErrorName, QueryGet, QueryInput, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryResultRow, QueryReturnType, QueryReturnsAll, QuerySelectAll, QueryThen, QueryUpsert, QueryWithTable, RawExpression, RawMethods, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationQueryData, RelationsBase, Select, SelectAgg, SelectArg, SelectFunctionItem, SelectItem, SelectQueryData, Selectable, SelectableBase, SerialColumn, SetOptional, SetQueryJoinedTables, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumnInfo, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWindows, SetQueryWith, SimpleSpread, SingleColumnIndexOptions, SinglePrimaryKey, SmallIntColumn, SmallSerialColumn, SomeIsTrue, SortDir, Spread, Sql, StringColumn, StringExpression, StringKey, TableData, TextBaseColumn, TextColumn, TextColumnData, Then, ThenResult, TimeColumn, TimeInterval, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, ToSqlCtx, ToSqlOptions, Transaction, TransactionAdapter, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnknownKeysParam, Update, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdatedAtDataInjector, UpsertData, UpsertResult, UpsertThis, ValidationContext, VarCharColumn, Where, WhereArg, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowFunctionOptions, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addQuestionMarks, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, applyMixins, array, arrayToEnum, baseObjectOutputType, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, flatten, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, identity, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
|
|
4346
|
+
export { Adapter, AdapterOptions, AddQueryJoinedTable, AddQuerySelect, AddQueryWith, AfterCallback, Aggregate, Aggregate1ArgumentTypes, AggregateArg, AggregateItem, AggregateItemArg, AggregateItemOptions, AggregateOptions, AliasOrTable, AnyColumnType, AnyColumnTypeCreator, ArrayCardinality, ArrayColumn, ArrayData, ArrayOfColumnsObjects, AssertArray, BaseNumberData, BaseRelation, BaseStringData, BeforeCallback, BelongsToNestedInsert, BelongsToNestedUpdate, BelongsToRelation, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BooleanExpression, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ClearStatement, CoalesceString, ColumnData, ColumnInfo, ColumnInfoMethods, ColumnInfoQueryData, ColumnInput, ColumnNameOfModel, ColumnOperators, ColumnOutput, ColumnParser, ColumnShapeInput, ColumnShapeOutput, ColumnType, ColumnTypes, ColumnTypesBase, ColumnsObject, ColumnsParsers, ColumnsShape, CommonQueryData, Create, CreateData, CreateMethodsNames, DateBaseColumn, DateColumn, DateColumnData, DateTimeBaseClass, DateTimeColumnData, DateTimeWithTimeZoneBaseClass, Db, DbOptions, DbTableOptions, DecimalBaseColumn, DecimalColumn, DecimalColumnData, DeepPartial, DefaultSelectColumns, Delete, DeleteMethodsNames, DeleteQueryData, DoublePrecisionColumn, DropMode, EMPTY_OBJECT, EmptyObject, EnumColumn, EnumLike, Except, Expression, ExpressionOfType, ExpressionOutput, FilterTuple, For, ForeignKey, ForeignKeyModel, ForeignKeyModelWithColumns, ForeignKeyOptions, From, GetArg, HasAndBelongsToManyRelation, HasManyNestedInsert, HasManyNestedUpdate, HasManyRelation, HasOneNestedInsert, HasOneNestedUpdate, HasOneRelation, Having, HavingArg, HavingItem, IndexColumnOptions, IndexOptions, InetColumn, InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, IsEqual, JSONAny, JSONArray, JSONBigInt, JSONBoolean, JSONColumn, JSONDate, JSONDiscriminatedObject, JSONDiscriminatedUnion, JSONEnum, JSONInstanceOf, JSONIntersection, JSONLazy, JSONLiteral, JSONMap, JSONNaN, JSONNativeEnum, JSONNever, JSONNotNullable, JSONNotNullish, JSONNull, JSONNullable, JSONNullish, JSONNumber, JSONObject, JSONObjectShape, JSONOptional, JSONRecord, JSONRecordKeyType, JSONRequired, JSONSet, JSONString, JSONTextColumn, JSONTuple, JSONTupleItems, JSONType, JSONTypeAny, JSONTypeData, JSONTypes, JSONUndefined, JSONUnion, JSONUnknown, JSONVoid, Join, JoinArgs, JoinCallback, JoinCallbackArg, JoinItem, JoinedTablesBase, Json, JsonItem, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MaybeArray, Merge, MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NestedInsertItem, NestedInsertManyItems, NestedInsertOneItem, NestedUpdateItem, NestedUpdateManyItems, NestedUpdateOneItem, NotFoundError, NullableColumn, NumberAsStringBaseColumn, NumberBaseColumn, NumberColumn, NumberColumnData, NumberExpression, OnConflictItem, OnConflictMergeUpdate, OnConflictQueryBuilder, OnQueryBuilder, Operator, Operators, OrderArg, OrderItem, OutputTypeOfTuple, OutputTypeOfTupleWithRest, OwnTypeProps, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, Primitive, Query, QueryArraysResult, QueryBase, QueryCallbacks, QueryData, QueryError, QueryErrorName, QueryGet, QueryInput, QueryLog, QueryLogObject, QueryLogOptions, QueryLogger, QueryMethods, QueryResult, QueryResultRow, QueryReturnType, QueryReturnsAll, QuerySelectAll, QueryThen, QueryUpsert, QueryWithTable, RawExpression, RawMethods, RealColumn, Relation, RelationQuery, RelationQueryBase, RelationQueryData, RelationsBase, Select, SelectAgg, SelectArg, SelectFunctionItem, SelectItem, SelectQueryData, Selectable, SelectableBase, SerialColumn, SetOptional, SetQueryJoinedTables, SetQueryReturns, SetQueryReturnsAll, SetQueryReturnsColumnInfo, SetQueryReturnsOne, SetQueryReturnsOneOptional, SetQueryReturnsPluck, SetQueryReturnsRowCount, SetQueryReturnsRows, SetQueryReturnsValue, SetQueryReturnsValueOptional, SetQueryReturnsVoid, SetQueryTableAlias, SetQueryWindows, SetQueryWith, SimpleSpread, SingleColumnIndexOptions, SinglePrimaryKey, SmallIntColumn, SmallSerialColumn, SomeIsTrue, SortDir, Spread, Sql, StringColumn, StringExpression, StringKey, TableData, TextBaseColumn, TextColumn, TextColumnData, Then, ThenResult, TimeColumn, TimeInterval, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, ToSqlCtx, ToSqlOptions, Transaction, TransactionAdapter, TruncateQueryData, TsQueryColumn, TsVectorColumn, TypeParsers, UUIDColumn, UnhandledTypeError, Union, UnionArg, UnionItem, UnknownKeysParam, Update, UpdateData, UpdateQueryData, UpdateQueryDataItem, UpdateQueryDataObject, UpdatedAtDataInjector, UpsertData, UpsertResult, UpsertThis, ValidationContext, VarCharColumn, Where, WhereArg, WhereInArg, WhereInColumn, WhereInItem, WhereInValues, WhereItem, WhereJsonPathEqualsItem, WhereOnItem, WhereOnJoinItem, WhereQueryBuilder, WhereResult, WindowArg, WindowArgDeclaration, WindowDeclaration, WindowFunctionOptions, WindowItem, With, WithDataBase, WithDataItem, WithItem, WithOptions, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addQuestionMarks, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, anyShape, applyMixins, array, arrayToEnum, baseObjectOutputType, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, flatten, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, identity, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
|
package/dist/index.esm.js
CHANGED
|
@@ -66,6 +66,9 @@ class ColumnType {
|
|
|
66
66
|
this.parseItem = fn;
|
|
67
67
|
return this;
|
|
68
68
|
}
|
|
69
|
+
as(_) {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
69
72
|
toSQL() {
|
|
70
73
|
return this.dataType;
|
|
71
74
|
}
|
|
@@ -1949,6 +1952,14 @@ class DateBaseColumn extends ColumnType {
|
|
|
1949
1952
|
this.data = {};
|
|
1950
1953
|
this.operators = Operators.date;
|
|
1951
1954
|
}
|
|
1955
|
+
asNumber() {
|
|
1956
|
+
return this.encode((input) => new Date(input)).parse(
|
|
1957
|
+
Date.parse
|
|
1958
|
+
);
|
|
1959
|
+
}
|
|
1960
|
+
asDate() {
|
|
1961
|
+
return this.parse((input) => new Date(input));
|
|
1962
|
+
}
|
|
1952
1963
|
}
|
|
1953
1964
|
assignMethodsToClass(DateBaseColumn, dateTypeMethods);
|
|
1954
1965
|
class DateColumn extends DateBaseColumn {
|
|
@@ -4174,8 +4185,9 @@ const handleSelect = (q) => {
|
|
|
4174
4185
|
q.query.select = ["*"];
|
|
4175
4186
|
}
|
|
4176
4187
|
};
|
|
4177
|
-
const processCreateItem = (item, rowIndex, ctx, columns, columnsMap) => {
|
|
4188
|
+
const processCreateItem = (item, rowIndex, ctx, columns, encoders, columnsMap, shape) => {
|
|
4178
4189
|
Object.keys(item).forEach((key) => {
|
|
4190
|
+
var _a;
|
|
4179
4191
|
if (ctx.relations[key]) {
|
|
4180
4192
|
if (ctx.relations[key].type === "belongsTo") {
|
|
4181
4193
|
const foreignKey = ctx.relations[key].options.foreignKey;
|
|
@@ -4200,8 +4212,9 @@ const processCreateItem = (item, rowIndex, ctx, columns, columnsMap) => {
|
|
|
4200
4212
|
item[key]
|
|
4201
4213
|
]);
|
|
4202
4214
|
}
|
|
4203
|
-
} else if (columnsMap[key] === void 0) {
|
|
4215
|
+
} else if (columnsMap[key] === void 0 && (shape[key] || shape === anyShape)) {
|
|
4204
4216
|
columnsMap[key] = columns.length;
|
|
4217
|
+
encoders[key] = (_a = shape[key]) == null ? void 0 : _a.encodeFn;
|
|
4205
4218
|
columns.push(key);
|
|
4206
4219
|
}
|
|
4207
4220
|
});
|
|
@@ -4228,30 +4241,37 @@ const getManyReturnType = (q) => {
|
|
|
4228
4241
|
return "rowCount";
|
|
4229
4242
|
}
|
|
4230
4243
|
};
|
|
4244
|
+
const mapColumnValues = (columns, encoders, data) => {
|
|
4245
|
+
return columns.map(
|
|
4246
|
+
(key) => encoders[key] ? encoders[key](data[key]) : data[key]
|
|
4247
|
+
);
|
|
4248
|
+
};
|
|
4231
4249
|
const handleOneData = (q, data, ctx) => {
|
|
4232
4250
|
const columns = [];
|
|
4251
|
+
const encoders = {};
|
|
4233
4252
|
const columnsMap = {};
|
|
4234
4253
|
const defaults = q.query.defaults;
|
|
4235
4254
|
if (defaults) {
|
|
4236
4255
|
data = __spreadValues$4(__spreadValues$4({}, defaults), data);
|
|
4237
4256
|
}
|
|
4238
|
-
processCreateItem(data, 0, ctx, columns, columnsMap);
|
|
4239
|
-
const values = [columns
|
|
4257
|
+
processCreateItem(data, 0, ctx, columns, encoders, columnsMap, q.shape);
|
|
4258
|
+
const values = [mapColumnValues(columns, encoders, data)];
|
|
4240
4259
|
return { columns, values };
|
|
4241
4260
|
};
|
|
4242
4261
|
const handleManyData = (q, data, ctx) => {
|
|
4243
4262
|
const columns = [];
|
|
4263
|
+
const encoders = {};
|
|
4244
4264
|
const columnsMap = {};
|
|
4245
4265
|
const defaults = q.query.defaults;
|
|
4246
4266
|
if (defaults) {
|
|
4247
4267
|
data = data.map((item) => __spreadValues$4(__spreadValues$4({}, defaults), item));
|
|
4248
4268
|
}
|
|
4249
4269
|
data.forEach((item, i) => {
|
|
4250
|
-
processCreateItem(item, i, ctx, columns, columnsMap);
|
|
4270
|
+
processCreateItem(item, i, ctx, columns, encoders, columnsMap, q.shape);
|
|
4251
4271
|
});
|
|
4252
4272
|
const values = Array(data.length);
|
|
4253
4273
|
data.forEach((item, i) => {
|
|
4254
|
-
values[i] = columns
|
|
4274
|
+
values[i] = mapColumnValues(columns, encoders, item);
|
|
4255
4275
|
});
|
|
4256
4276
|
return { columns, values };
|
|
4257
4277
|
};
|
|
@@ -5123,7 +5143,7 @@ class Update {
|
|
|
5123
5143
|
const data = args[0];
|
|
5124
5144
|
const set = __spreadValues$1({}, data);
|
|
5125
5145
|
pushQueryValue(this, "updateData", set);
|
|
5126
|
-
const relations = this
|
|
5146
|
+
const { relations, shape } = this;
|
|
5127
5147
|
const prependRelations = {};
|
|
5128
5148
|
const appendRelations = {};
|
|
5129
5149
|
const originalReturnType = query.returnType || "all";
|
|
@@ -5141,6 +5161,12 @@ class Update {
|
|
|
5141
5161
|
}
|
|
5142
5162
|
appendRelations[key] = data[key];
|
|
5143
5163
|
}
|
|
5164
|
+
} else if (!shape[key] && shape !== anyShape) {
|
|
5165
|
+
delete set[key];
|
|
5166
|
+
} else {
|
|
5167
|
+
const encode = shape[key].encodeFn;
|
|
5168
|
+
if (encode)
|
|
5169
|
+
set[key] = encode(set[key]);
|
|
5144
5170
|
}
|
|
5145
5171
|
}
|
|
5146
5172
|
const state = {};
|
|
@@ -5605,8 +5631,9 @@ var __objRest = (source, exclude) => {
|
|
|
5605
5631
|
}
|
|
5606
5632
|
return target;
|
|
5607
5633
|
};
|
|
5634
|
+
const anyShape = {};
|
|
5608
5635
|
class Db {
|
|
5609
|
-
constructor(adapter, queryBuilder, table = void 0, shape =
|
|
5636
|
+
constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, options) {
|
|
5610
5637
|
this.adapter = adapter;
|
|
5611
5638
|
this.queryBuilder = queryBuilder;
|
|
5612
5639
|
this.table = table;
|
|
@@ -5710,5 +5737,5 @@ const createDb = (_a) => {
|
|
|
5710
5737
|
return db;
|
|
5711
5738
|
};
|
|
5712
5739
|
|
|
5713
|
-
export { Adapter, Aggregate, ArrayColumn, ArrayOfColumnsObjects, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ColumnInfoMethods, ColumnType, ColumnsObject, Create, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeWithTimeZoneBaseClass, Db, DecimalBaseColumn, DecimalColumn, Delete, DoublePrecisionColumn, EMPTY_OBJECT, EnumColumn, For, From, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, Json, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnQueryBuilder, Operators, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, QueryCallbacks, QueryError, QueryGet, QueryLog, QueryMethods, QueryUpsert, RawMethods, RealColumn, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, Transaction, TransactionAdapter, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, Update, VarCharColumn, Where, WhereQueryBuilder, With, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, applyMixins, array, arrayToEnum, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
|
|
5740
|
+
export { Adapter, Aggregate, ArrayColumn, ArrayOfColumnsObjects, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, Clear, ColumnInfoMethods, ColumnType, ColumnsObject, Create, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeWithTimeZoneBaseClass, Db, DecimalBaseColumn, DecimalColumn, Delete, DoublePrecisionColumn, EMPTY_OBJECT, EnumColumn, For, From, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, Json, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnQueryBuilder, Operators, PathColumn, PluckResultColumnType, PointColumn, PolygonColumn, PormError, PormInternalError, QueryCallbacks, QueryError, QueryGet, QueryLog, QueryMethods, QueryUpsert, RawMethods, RealColumn, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimeWithTimeZoneColumn, TimestampColumn, TimestampWithTimeZoneColumn, Transaction, TransactionAdapter, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, Update, VarCharColumn, Where, WhereQueryBuilder, With, XMLColumn, addOr, addOrNot, addParserForRawExpression, addParserForSelectItem, addParserToQuery, addQueryOn, addQueryOrOn, addWhere, addWhereIn, addWhereNot, aggregate1FunctionNames, anyShape, applyMixins, array, arrayToEnum, checkIfASimpleQuery, columnTypes, utils as columnUtils, constructType, createDb, createOperator, defaultsKey, discriminatedUnion, emptyObject, enumType, getClonedQueryData, getColumnTypes, getQueryAs, getQueryParsers, getRaw, getRawSql, getTableData, getValidEnumValues, getValueKey, handleResult, instanceOf, intersection, isRaw, isRequiredRelationKey, joinTruthy, jsonTypes, lazy, literal, logColors, logParamToLogObject, makeRegexToFindInSql, map, nativeEnum, newTableData, noop, notNullable, notNullish, nullable, nullish, object, optional, parseRecord, parseResult, processSelectArg, pushOrNewArray, pushOrNewArrayToObject, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, queryMethodByReturnType, queryTypeWithLimitOne, quote, raw, record, relationQueryKey, required, resetTableData, scalarTypes, set, setQueryObjectValue, toArray, toSql, toSqlCacheKey, tuple, union };
|
|
5714
5741
|
//# sourceMappingURL=index.esm.js.map
|