symmetria 1.0.1 → 1.0.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.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1796,6 +1796,15 @@ const createQueryFactory = (registry, executor, profile, hold) => {
|
|
|
1796
1796
|
}
|
|
1797
1797
|
return allowScopedAlias ? registry.scopedPlan(state.root) : initialPlan(state.root);
|
|
1798
1798
|
};
|
|
1799
|
+
/**
|
|
1800
|
+
* The plan a terminal runs. A bare table or alias handle (`scoped.posts`,
|
|
1801
|
+
* `scoped.posts.as("p")`) keeps the plan built when it was created, so its
|
|
1802
|
+
* `$scope()` predicates are evaluated again here, like every new query does.
|
|
1803
|
+
*/
|
|
1804
|
+
const currentPlan = (handle) => {
|
|
1805
|
+
const { plan, freshSource, allowScopedAlias } = handle[QUERY_STATE];
|
|
1806
|
+
return freshSource && allowScopedAlias && registry.scopes[plan.root.table.name] ? registry.scopedPlan(plan.root) : plan;
|
|
1807
|
+
};
|
|
1799
1808
|
const single = async (state, required) => {
|
|
1800
1809
|
if (typeof state.limit === "object") throw new Error("symmetria: bind a parameterized LIMIT with prepare()");
|
|
1801
1810
|
const rows = (await executePlan(limitedPlan(state, 2), executor)).rows;
|
|
@@ -1947,10 +1956,10 @@ const createQueryFactory = (registry, executor, profile, hold) => {
|
|
|
1947
1956
|
return (await executePlan(limitedPlan(state, 1), executor)).rows[0] ?? null;
|
|
1948
1957
|
},
|
|
1949
1958
|
async count() {
|
|
1950
|
-
return readCount((await executePlan(countPlan(this
|
|
1959
|
+
return readCount((await executePlan(countPlan(currentPlan(this)), executor)).rows);
|
|
1951
1960
|
},
|
|
1952
1961
|
async exists() {
|
|
1953
|
-
return readExists((await executePlan(existsPlan(this
|
|
1962
|
+
return readExists((await executePlan(existsPlan(currentPlan(this), false), executor)).rows);
|
|
1954
1963
|
}
|
|
1955
1964
|
})));
|
|
1956
1965
|
const createQuery = (state, allowScopedAlias = false, freshSource = false, prototype = queryPrototype, sharedRoot = false) => {
|