pqb 0.61.12 → 0.61.13
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 +4 -4
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9553,8 +9553,9 @@ const whereToSql = (ctx, table, query, quotedAs, parens) => {
|
|
|
9553
9553
|
const data = Object.create(query);
|
|
9554
9554
|
for (const key in query.scopes) {
|
|
9555
9555
|
const scope = query.scopes[key];
|
|
9556
|
-
|
|
9557
|
-
data.
|
|
9556
|
+
const scopeResult = scope(table.baseQuery);
|
|
9557
|
+
data.and = scopeResult.and;
|
|
9558
|
+
data.or = scopeResult.or;
|
|
9558
9559
|
const scopeSql = andOrToSql(ctx, table, data, quotedAs, true);
|
|
9559
9560
|
if (scopeSql) sql = sql ? sql + " AND " + scopeSql : scopeSql;
|
|
9560
9561
|
}
|
|
@@ -14763,9 +14764,7 @@ function enableSoftDelete(query, table, shape, softDelete, scopes) {
|
|
|
14763
14764
|
`Table ${table} is missing ${column} column which is required for soft delete`
|
|
14764
14765
|
);
|
|
14765
14766
|
}
|
|
14766
|
-
const scope = {
|
|
14767
|
-
and: [{ [column]: null }]
|
|
14768
|
-
};
|
|
14767
|
+
const scope = () => ({ and: [{ [column]: null }] });
|
|
14769
14768
|
scopes.deleted = scope;
|
|
14770
14769
|
const { q } = query;
|
|
14771
14770
|
setObjectValueImmutable(q, "scopes", "nonDeleted", scope);
|
|
@@ -15834,10 +15833,10 @@ class Db extends QueryMethods {
|
|
|
15834
15833
|
};
|
|
15835
15834
|
if (options.scopes) {
|
|
15836
15835
|
for (const key in options.scopes) {
|
|
15837
|
-
const
|
|
15838
|
-
scopes[key] = {
|
|
15839
|
-
|
|
15840
|
-
or: q.or
|
|
15836
|
+
const scopeFn = options.scopes[key];
|
|
15837
|
+
scopes[key] = (q) => {
|
|
15838
|
+
const result = scopeFn(q);
|
|
15839
|
+
return { and: result.q.and, or: result.q.or };
|
|
15841
15840
|
};
|
|
15842
15841
|
}
|
|
15843
15842
|
if (scopes.default) {
|