pqb 0.66.1 → 0.66.3
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 +3 -12
- package/dist/index.js +19 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -23
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +0 -6
- package/dist/internal.mjs +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -287,12 +287,6 @@ const rollbackSql = { text: "ROLLBACK" };
|
|
|
287
287
|
const quoteIdentifier = (role) => {
|
|
288
288
|
return `"${role.replace(/"/g, "\"\"")}"`;
|
|
289
289
|
};
|
|
290
|
-
/**
|
|
291
|
-
* Symbol that turns on a snake case column names.
|
|
292
|
-
* It is set on the column types.
|
|
293
|
-
* When it's on, column names in ORM are still as user types them, but they are translated to snake_case when generating SQL.
|
|
294
|
-
*/
|
|
295
|
-
const snakeCaseKey = Symbol("snakeCase");
|
|
296
290
|
var Expression = class {
|
|
297
291
|
toSQL(ctx, quotedAs) {
|
|
298
292
|
let sql = this.makeSQL(ctx, quotedAs);
|
|
@@ -462,7 +456,7 @@ const makeIndex = (columns, first, second) => {
|
|
|
462
456
|
} };
|
|
463
457
|
else return { index: {
|
|
464
458
|
columns,
|
|
465
|
-
options: first
|
|
459
|
+
options: { ...first }
|
|
466
460
|
} };
|
|
467
461
|
};
|
|
468
462
|
const tableDataMethods = {
|
|
@@ -2028,10 +2022,10 @@ var ArrayColumn = class ArrayColumn extends Column {
|
|
|
2028
2022
|
}
|
|
2029
2023
|
const code = [open];
|
|
2030
2024
|
const { item } = this.data;
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2025
|
+
const clonedItem = Object.create(item);
|
|
2026
|
+
const { isNullable: _, ...dataWithoutNullable } = item.data;
|
|
2027
|
+
clonedItem.data = dataWithoutNullable;
|
|
2028
|
+
addCode(code, clonedItem.toCode(ctx, key));
|
|
2035
2029
|
addCode(code, `${close}${arrayDataToCode(this.data, ctx.migration)}`);
|
|
2036
2030
|
return columnCode(this, ctx, key, code);
|
|
2037
2031
|
}
|
|
@@ -3924,6 +3918,7 @@ const applyComputedColumns = (q, fn) => {
|
|
|
3924
3918
|
for (const key in computed) {
|
|
3925
3919
|
let item = computed[key];
|
|
3926
3920
|
if (typeof item === "function") item = item.call(computed);
|
|
3921
|
+
item = Object.create(item);
|
|
3927
3922
|
if (item instanceof ComputedColumn) q.q.runtimeComputeds = {
|
|
3928
3923
|
...q.q.runtimeComputeds,
|
|
3929
3924
|
[key]: item
|
|
@@ -3931,7 +3926,7 @@ const applyComputedColumns = (q, fn) => {
|
|
|
3931
3926
|
else {
|
|
3932
3927
|
let col = item.result.value;
|
|
3933
3928
|
if (!col) {
|
|
3934
|
-
item.result
|
|
3929
|
+
item.result = { value: col = Object.create(UnknownColumn.instance) };
|
|
3935
3930
|
col.data = { ...col.data };
|
|
3936
3931
|
}
|
|
3937
3932
|
q.shape[key] = col;
|
|
@@ -3939,7 +3934,7 @@ const applyComputedColumns = (q, fn) => {
|
|
|
3939
3934
|
data.computed = item;
|
|
3940
3935
|
data.explicitSelect = true;
|
|
3941
3936
|
data.readOnly = true;
|
|
3942
|
-
const parse =
|
|
3937
|
+
const parse = col._parse;
|
|
3943
3938
|
if (parse) (q.q.defaultParsers ??= {})[key] = parse;
|
|
3944
3939
|
}
|
|
3945
3940
|
}
|
|
@@ -4858,7 +4853,7 @@ function queryFrom(self, arg) {
|
|
|
4858
4853
|
arg = arg.slice(i + 1);
|
|
4859
4854
|
} else if (w) data.schema = void 0;
|
|
4860
4855
|
} else if (Array.isArray(arg)) {
|
|
4861
|
-
const { shape }
|
|
4856
|
+
const shape = { ...data.shape };
|
|
4862
4857
|
const joinedParsers = {};
|
|
4863
4858
|
for (const item of arg) if (typeof item === "string") {
|
|
4864
4859
|
const w = data.withShapes[item];
|
|
@@ -6920,7 +6915,7 @@ const pushIn = (ctx, query, ands, quotedAs, arg) => {
|
|
|
6920
6915
|
const columnsSql = arg.columns.map((column) => columnToSql(ctx, query, query.shape, column, quotedAs)).join(", ");
|
|
6921
6916
|
ands.push(`${multiple ? `(${columnsSql})` : columnsSql} IN ${value}`);
|
|
6922
6917
|
};
|
|
6923
|
-
const MAX_BINDING_PARAMS =
|
|
6918
|
+
const MAX_BINDING_PARAMS = 65533;
|
|
6924
6919
|
const makeInsertSql = (ctx, q, query, quotedAs, isSubSql) => {
|
|
6925
6920
|
let { columns } = query;
|
|
6926
6921
|
const { shape, hookCreateSet } = query;
|
|
@@ -6995,8 +6990,8 @@ const makeInsertSql = (ctx, q, query, quotedAs, isSubSql) => {
|
|
|
6995
6990
|
let encodedRow = encodeRow(ctx, ctxValues, QueryClass, values[i], runtimeDefaults, quotedAs, hookSetSql);
|
|
6996
6991
|
ctx.skipBatchCheck = skipBatchCheck;
|
|
6997
6992
|
if (!upsert) encodedRow = "(" + encodedRow + ")";
|
|
6998
|
-
if (ctxValues.length >
|
|
6999
|
-
if (ctxValues.length - currentValuesLen >
|
|
6993
|
+
if (ctxValues.length > 65533) {
|
|
6994
|
+
if (ctxValues.length - currentValuesLen > 65533) throw new Error(`Too many parameters for a single insert row, max is ${MAX_BINDING_PARAMS}`);
|
|
7000
6995
|
if (!skipBatchCheck) {
|
|
7001
6996
|
setTopCteSize(ctx, topCteSize);
|
|
7002
6997
|
applySqlState(sqlState);
|
|
@@ -13231,12 +13226,11 @@ const performQuery = async (q, args, method) => {
|
|
|
13231
13226
|
}
|
|
13232
13227
|
};
|
|
13233
13228
|
var Db = class extends QueryMethods {
|
|
13234
|
-
constructor(adapterNotInTransaction, qb, table = void 0, shape
|
|
13229
|
+
constructor(adapterNotInTransaction, qb, table = void 0, shape, columnTypes, asyncStorage, options, tableData = {}) {
|
|
13235
13230
|
super();
|
|
13236
13231
|
this.adapterNotInTransaction = adapterNotInTransaction;
|
|
13237
13232
|
this.qb = qb;
|
|
13238
13233
|
this.table = table;
|
|
13239
|
-
this.shape = shape;
|
|
13240
13234
|
this.columnTypes = columnTypes;
|
|
13241
13235
|
const self = this;
|
|
13242
13236
|
const { softDelete } = options;
|
|
@@ -13253,8 +13247,12 @@ var Db = class extends QueryMethods {
|
|
|
13253
13247
|
let runtimeDefaultColumns;
|
|
13254
13248
|
let selectAllCount = 0;
|
|
13255
13249
|
const { snakeCase } = options;
|
|
13250
|
+
if (shape !== anyShape) shape = { ...shape };
|
|
13251
|
+
this.shape = shape;
|
|
13256
13252
|
for (const key in shape) {
|
|
13257
|
-
const column = shape[key];
|
|
13253
|
+
const column = Object.create(shape[key]);
|
|
13254
|
+
shape[key] = column;
|
|
13255
|
+
column.data = { ...column.data };
|
|
13258
13256
|
column.data.key = key;
|
|
13259
13257
|
if (column._parse) {
|
|
13260
13258
|
hasParsers = true;
|
|
@@ -13569,13 +13567,12 @@ const createDbWithAdapter = ({ log, logger, snakeCase, schemaConfig = defaultSch
|
|
|
13569
13567
|
snakeCase
|
|
13570
13568
|
};
|
|
13571
13569
|
const ct = typeof ctOrFn === "function" ? ctOrFn(makeColumnTypes(schemaConfig)) : ctOrFn;
|
|
13572
|
-
if (snakeCase) ct[snakeCaseKey] = true;
|
|
13573
13570
|
const asyncStorage = new AsyncLocalStorage();
|
|
13574
13571
|
const qb = _initQueryBuilder(adapter, ct, asyncStorage, commonOptions, options);
|
|
13575
13572
|
commonOptions.schema = schema;
|
|
13576
13573
|
const { nowSQL } = options;
|
|
13577
13574
|
const tableConstructor = (table, shape, dataFn, options) => {
|
|
13578
|
-
return new Db(adapter, qb, table, typeof shape === "function" ? getColumnTypes(ct, shape, nowSQL, options?.language) : shape, ct, asyncStorage, {
|
|
13575
|
+
return new Db(adapter, qb, table, typeof shape === "function" ? getColumnTypes(ct, shape, nowSQL, options?.language) : shape || anyShape, ct, asyncStorage, {
|
|
13579
13576
|
...commonOptions,
|
|
13580
13577
|
...options
|
|
13581
13578
|
}, parseTableData(dataFn));
|
|
@@ -14211,6 +14208,6 @@ const testTransaction = {
|
|
|
14211
14208
|
if (db.internal[trxForTest]?.length === 0) return db.q.adapter.close();
|
|
14212
14209
|
}
|
|
14213
14210
|
};
|
|
14214
|
-
export { AdapterClass, ArrayColumn, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Column, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, Expression, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MoneyColumn, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, Operators, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryError, QueryHookUtils, QueryHooks, RawSql, RealColumn, SerialColumn, SmallIntColumn, SmallSerialColumn, StringColumn, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, TransactionAdapterClass, TsQueryColumn, TsVectorColumn, UUIDColumn, UnknownColumn, VarCharColumn, VirtualColumn, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote,
|
|
14211
|
+
export { AdapterClass, ArrayColumn, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Column, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, Expression, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MoneyColumn, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, Operators, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryError, QueryHookUtils, QueryHooks, RawSql, RealColumn, SerialColumn, SmallIntColumn, SmallSerialColumn, StringColumn, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, TransactionAdapterClass, TsQueryColumn, TsVectorColumn, UUIDColumn, UnknownColumn, VarCharColumn, VirtualColumn, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|
|
14215
14212
|
|
|
14216
14213
|
//# sourceMappingURL=index.mjs.map
|