bazis 0.113.0 → 0.114.0
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.
|
@@ -232,7 +232,7 @@ export class CodexAppServerClient implements CodexClient {
|
|
|
232
232
|
if (method === "account/updated") this.modelCache = undefined;
|
|
233
233
|
}, () => { this.clearLogin(); this.modelCache = undefined; });
|
|
234
234
|
const initialized = await client.request("initialize", {
|
|
235
|
-
clientInfo: { name: "bazis", title: "Bazis", version: "0.
|
|
235
|
+
clientInfo: { name: "bazis", title: "Bazis", version: "0.114.0" }, capabilities: { experimentalApi: true },
|
|
236
236
|
}, 15_000, signal);
|
|
237
237
|
if (resolve(text(initialized.codexHome, 4096)) !== this.paths.home) throw new CodexError("PROTOCOL_ERROR");
|
|
238
238
|
client.notify("initialized");
|
|
@@ -164,7 +164,7 @@ export class EntityQuery<T extends object, TResult = T> {
|
|
|
164
164
|
result[i] = entity;
|
|
165
165
|
}
|
|
166
166
|
if (this.plan.includes.length > 0) {
|
|
167
|
-
await new IncludeLoader(this.runtime).load(this.model, result as object[], this.plan.includes, this.plan.noTracking);
|
|
167
|
+
await new IncludeLoader(this.runtime, this.plan.ignoreQueryFilters).load(this.model, result as object[], this.plan.includes, this.plan.noTracking);
|
|
168
168
|
}
|
|
169
169
|
return result as unknown as TResult[];
|
|
170
170
|
}
|
|
@@ -19,7 +19,11 @@ interface Level {
|
|
|
19
19
|
* together in memory. This avoids the Cartesian product of collection JOINs.
|
|
20
20
|
*/
|
|
21
21
|
export class IncludeLoader {
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* `ignoreQueryFilters` comes from the main query: when it turned the filters
|
|
24
|
+
* off, included entities are read without them too (as in EF Core).
|
|
25
|
+
*/
|
|
26
|
+
constructor(private readonly runtime: DbContextRuntime, private readonly ignoreQueryFilters = false) {}
|
|
23
27
|
|
|
24
28
|
async load(rootModel: EntityModel, roots: object[], paths: readonly (readonly string[])[], noTracking: boolean): Promise<void> {
|
|
25
29
|
if (roots.length === 0) {
|
|
@@ -156,14 +160,19 @@ export class IncludeLoader {
|
|
|
156
160
|
return model.key[0];
|
|
157
161
|
}
|
|
158
162
|
|
|
163
|
+
private translator(model: EntityModel): SqlTranslator {
|
|
164
|
+
return new SqlTranslator(model, this.runtime.provider.dialect, this.ignoreQueryFilters ? [] : effectiveQueryFilters(model, this.runtime.context));
|
|
165
|
+
}
|
|
166
|
+
|
|
159
167
|
private async queryIn(model: EntityModel, property: string, values: readonly unknown[], noTracking: boolean): Promise<object[]> {
|
|
160
|
-
const translator =
|
|
168
|
+
const translator = this.translator(model);
|
|
161
169
|
const result: object[] = [];
|
|
162
170
|
const chunkSize = maxParametersPerInList(this.runtime.provider);
|
|
163
171
|
for (let start = 0; start < values.length; start += chunkSize) {
|
|
164
172
|
const chunk = values.slice(start, start + chunkSize);
|
|
165
173
|
const { sql, params } = translator.selectAll({
|
|
166
174
|
...EMPTY_PLAN,
|
|
175
|
+
ignoreQueryFilters: this.ignoreQueryFilters,
|
|
167
176
|
conditions: [{ kind: "in", property, values: chunk }],
|
|
168
177
|
noTracking,
|
|
169
178
|
});
|
|
@@ -181,7 +190,7 @@ export class IncludeLoader {
|
|
|
181
190
|
|
|
182
191
|
private async queryTuples(model: EntityModel, properties: readonly string[], values: readonly (readonly unknown[])[], noTracking: boolean): Promise<object[]> {
|
|
183
192
|
const result: object[] = []; const perTuple = properties.length; const chunkSize = Math.max(1, Math.floor(maxParametersPerInList(this.runtime.provider) / perTuple));
|
|
184
|
-
for (let start = 0; start < values.length; start += chunkSize) { const translator =
|
|
193
|
+
for (let start = 0; start < values.length; start += chunkSize) { const translator = this.translator(model); const { sql, params } = translator.selectAll({ ...EMPTY_PLAN, ignoreQueryFilters: this.ignoreQueryFilters, conditions: [{ kind: "tuples", properties, values: values.slice(start, start + chunkSize) }], noTracking }); for (let entity of (await this.runtime.provider.query(sql, params)).map((row) => materialize<object>(model, row, this.runtime.provider.dialect))) { if (!noTracking) entity = this.runtime.tracker.trackLoaded(entity, model); result.push(entity); } }
|
|
185
194
|
return result;
|
|
186
195
|
}
|
|
187
196
|
private tuple(model: EntityModel, values: readonly unknown[]): string | undefined {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bazis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.114.0",
|
|
4
4
|
"description": "Modular backend framework for Bun in TypeScript: DI wired by codegen, HTTP, a PostgreSQL ORM, JWT, WebSocket, agents and a CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alexander Alenin",
|