pqb 0.67.1 → 0.67.2
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 +38 -26
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -0
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +9490 -2
- package/dist/internal.js +17 -0
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +17 -1
- package/dist/internal.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3478,6 +3478,11 @@ var NestedSqlSessionError = class extends OrchidOrmInternalError {
|
|
|
3478
3478
|
super(query, "Cannot nest SQL session scopes. Outer scope already has role or setConfig defined.");
|
|
3479
3479
|
}
|
|
3480
3480
|
};
|
|
3481
|
+
var CannotMutateReadOnlyTableError = class extends OrchidOrmInternalError {
|
|
3482
|
+
constructor(query) {
|
|
3483
|
+
super(query, "Cannot mutate a readonly table.");
|
|
3484
|
+
}
|
|
3485
|
+
};
|
|
3481
3486
|
const escape = (value, migration, nested) => {
|
|
3482
3487
|
const type = typeof value;
|
|
3483
3488
|
if (type === "number" || type === "bigint") return String(value);
|
|
@@ -5160,6 +5165,9 @@ const throwIfNoWhere = (q, method) => {
|
|
|
5160
5165
|
const throwIfJoinLateral = (q, method) => {
|
|
5161
5166
|
if (q.q.join?.some((x) => Array.isArray(x) || "s" in x.args && x.args.s)) throw new OrchidOrmInternalError(q, `Cannot join a complex query in ${method}`);
|
|
5162
5167
|
};
|
|
5168
|
+
const throwIfReadOnly = (query) => {
|
|
5169
|
+
if (query.internal.readOnly) throw new CannotMutateReadOnlyTableError(query);
|
|
5170
|
+
};
|
|
5163
5171
|
const throwOnReadOnlyUpdate = (query, column, key) => {
|
|
5164
5172
|
if (column.data.appReadOnly || column.data.readOnly) throw new OrchidOrmInternalError(query, "Trying to update a readonly column", { column: key });
|
|
5165
5173
|
};
|
|
@@ -8457,6 +8465,7 @@ var AggregateMethods = class {
|
|
|
8457
8465
|
* @param data - optionally passed custom data when creating a single record.
|
|
8458
8466
|
*/
|
|
8459
8467
|
const insertFrom = (query, from, many, queryMany, data) => {
|
|
8468
|
+
throwIfReadOnly(query);
|
|
8460
8469
|
const ctx = createCtx();
|
|
8461
8470
|
const obj = data && (Array.isArray(data) ? handleManyData(query, data, ctx) : handleOneData(query, data, ctx));
|
|
8462
8471
|
return insert(query, {
|
|
@@ -8912,17 +8921,21 @@ const insert = (self, { columns, insertFrom, values }, many, queryMany) => {
|
|
|
8912
8921
|
return self;
|
|
8913
8922
|
};
|
|
8914
8923
|
const _queryCreate = (q, data) => {
|
|
8924
|
+
throwIfReadOnly(q);
|
|
8915
8925
|
createSelect(q);
|
|
8916
8926
|
return _queryInsert(q, data);
|
|
8917
8927
|
};
|
|
8918
8928
|
const _queryInsert = (query, data) => {
|
|
8929
|
+
throwIfReadOnly(query);
|
|
8919
8930
|
return insert(query, handleOneData(query, data, createCtx()));
|
|
8920
8931
|
};
|
|
8921
8932
|
const _queryCreateMany = (q, data) => {
|
|
8933
|
+
throwIfReadOnly(q);
|
|
8922
8934
|
createSelect(q);
|
|
8923
8935
|
return _queryInsertMany(q, data);
|
|
8924
8936
|
};
|
|
8925
8937
|
const _queryInsertMany = (q, data) => {
|
|
8938
|
+
throwIfReadOnly(q);
|
|
8926
8939
|
let result = insert(q, handleManyData(q, data, createCtx()), true);
|
|
8927
8940
|
if (!data.length) result = result.none();
|
|
8928
8941
|
return result;
|
|
@@ -11271,6 +11284,7 @@ var QueryGet = class {
|
|
|
11271
11284
|
}
|
|
11272
11285
|
};
|
|
11273
11286
|
const _queryDelete = (query) => {
|
|
11287
|
+
throwIfReadOnly(query);
|
|
11274
11288
|
const q = query.q;
|
|
11275
11289
|
if (!q.select) {
|
|
11276
11290
|
if (q.returnType === "oneOrThrow" || q.returnType === "valueOrThrow") q.throwOnNotFound = true;
|
|
@@ -11454,6 +11468,7 @@ var RefExpression = class extends Expression {
|
|
|
11454
11468
|
};
|
|
11455
11469
|
const _queryUpdateMany = (self, primaryKeys, data, strict) => {
|
|
11456
11470
|
const query = self;
|
|
11471
|
+
throwIfReadOnly(query);
|
|
11457
11472
|
const { q } = query;
|
|
11458
11473
|
const { shape } = q;
|
|
11459
11474
|
q.type = "update";
|
|
@@ -11473,6 +11488,7 @@ const _queryUpdateMany = (self, primaryKeys, data, strict) => {
|
|
|
11473
11488
|
return query;
|
|
11474
11489
|
};
|
|
11475
11490
|
const _queryChangeCounter = (self, op, data) => {
|
|
11491
|
+
throwIfReadOnly(self);
|
|
11476
11492
|
const q = self.q;
|
|
11477
11493
|
q.type = "update";
|
|
11478
11494
|
if (!q.select) {
|
|
@@ -11505,6 +11521,7 @@ const _queryChangeCounter = (self, op, data) => {
|
|
|
11505
11521
|
};
|
|
11506
11522
|
const _queryUpdate = (updateSelf, arg) => {
|
|
11507
11523
|
const query = updateSelf;
|
|
11524
|
+
throwIfReadOnly(query);
|
|
11508
11525
|
const { q } = query;
|
|
11509
11526
|
q.type = "update";
|
|
11510
11527
|
const set = { ...arg };
|
|
@@ -11832,6 +11849,7 @@ var QueryUpdate = class {
|
|
|
11832
11849
|
*/
|
|
11833
11850
|
updateFrom(arg, ...args) {
|
|
11834
11851
|
const q = _clone(this);
|
|
11852
|
+
throwIfReadOnly(q);
|
|
11835
11853
|
const joinArgs = _joinReturningArgs(q, true, arg, args, true);
|
|
11836
11854
|
if (!joinArgs) return _queryNone(q);
|
|
11837
11855
|
joinArgs.u = true;
|
|
@@ -13100,6 +13118,7 @@ var QueryTruncate = class {
|
|
|
13100
13118
|
* @param options - truncate options, may have `cascade: true` and `restartIdentity: true`
|
|
13101
13119
|
*/
|
|
13102
13120
|
truncate(options) {
|
|
13121
|
+
throwIfReadOnly(this);
|
|
13103
13122
|
const query = Object.create(_clone(this));
|
|
13104
13123
|
query.toSQL = () => makeTruncateSql(query, options);
|
|
13105
13124
|
return _queryExec(query);
|
|
@@ -13763,6 +13782,7 @@ var Db = class extends QueryMethods {
|
|
|
13763
13782
|
snakeCase: options.snakeCase,
|
|
13764
13783
|
noPrimaryKey: options.noPrimaryKey === "ignore",
|
|
13765
13784
|
comment: options.comment,
|
|
13785
|
+
readOnly: options.readOnly,
|
|
13766
13786
|
nowSQL: options.nowSQL,
|
|
13767
13787
|
tableData,
|
|
13768
13788
|
selectAllCount
|