@danceroutine/tango-orm 1.11.9 → 1.11.11
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/{QuerySetState-CjyvAUBs.d.ts → QuerySetState-C8NgnYTc.d.ts} +3 -1
- package/dist/{index-rjKca3U_.d.ts → index-O_dY4tRf.d.ts} +2 -2
- package/dist/{index-D9B6gKez.d.ts → index-d9NRHwNe.d.ts} +4 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/manager/index.d.ts +3 -3
- package/dist/manager/index.js +2 -2
- package/dist/{manager-DRra01q8.js → manager-VoPL1sc3.js} +2 -2
- package/dist/{manager-DRra01q8.js.map → manager-VoPL1sc3.js.map} +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/dist/{query-CP1UMIX6.js → query-D_93uktq.js} +47 -6
- package/dist/query-D_93uktq.js.map +1 -0
- package/dist/{registerModelObjects-CGjjOzd9.js → registerModelObjects-41ocGQmv.js} +12 -2
- package/dist/registerModelObjects-41ocGQmv.js.map +1 -0
- package/dist/{registerModelObjects-C-MliIiM.d.ts → registerModelObjects-UMxYImMK.d.ts} +2 -2
- package/dist/runtime/index.d.ts +2 -2
- package/dist/runtime/index.js +1 -1
- package/package.json +6 -6
- package/dist/query-CP1UMIX6.js.map +0 -1
- package/dist/registerModelObjects-CGjjOzd9.js.map +0 -1
|
@@ -77,6 +77,7 @@ declare class QueryCompiler {
|
|
|
77
77
|
constructor(meta: TableMeta, adapter: Adapter);
|
|
78
78
|
static isQueryCompiler(value: unknown): value is QueryCompiler;
|
|
79
79
|
compile<T, TSourceModel = unknown>(state: QuerySetState<T, TSourceModel>): CompiledQuery;
|
|
80
|
+
compileExists<T, TSourceModel = unknown>(state: QuerySetState<T, TSourceModel>): CompiledQuery;
|
|
80
81
|
compilePrefetch(node: CompiledHydrationNode, sourceValues: readonly (string | number)[]): CompiledPrefetchQuery;
|
|
81
82
|
compileManyToManyTargets(node: CompiledHydrationNode, targetIds: readonly (string | number)[]): {
|
|
82
83
|
sql: string;
|
|
@@ -245,6 +246,7 @@ declare abstract class QuerySet<TModel extends Record<string, unknown>, TBaseRes
|
|
|
245
246
|
* reaching into a base-class instance's protected state.
|
|
246
247
|
*/
|
|
247
248
|
protected static buildOrderSpecs<T extends Record<string, unknown>>(tokens: readonly OrderToken<T>[]): OrderSpec<T>[];
|
|
249
|
+
private static validateQueryWindowBound;
|
|
248
250
|
private static invertOrderSpec;
|
|
249
251
|
/**
|
|
250
252
|
* Add a filter expression to the query.
|
|
@@ -1307,4 +1309,4 @@ interface QuerySetState<T, TSourceModel = unknown> {
|
|
|
1307
1309
|
}
|
|
1308
1310
|
//#endregion
|
|
1309
1311
|
export { QBuilder as A, index_d_exports$2 as B, ReverseSingleRelations as C, ManyToManyRelatedManagerCreateInputs as D, ManyToManyRelatedManager as E, QNode as F, TableMeta as H, FilterInput as I, FilterValue as L, QueryExecutor as M, QuerySet as N, ManyToManyTargetRef as O, OrderToken as P, FilterKey as R, ReverseCollectionRelations as S, SingleRelationHydrationCardinality as T, QueryResult as U, QueryCompiler as V, ManyRelationHydrationCardinality as _, TableMetaFactory as a, RelationHydrationCardinality as b, RelationMeta as c, GeneratedPrefetchRelatedPathKeys as d, GeneratedRelationFilterKeys as f, InternalRelationHydrationCardinality as g, HydratedRelationMap as h, WhereClause as i, ModelQuerySet as j, index_d_exports$1 as k, ForwardSingleRelations as l, HydratedQueryResult as m, OrderSpec as n, Direction as o, GeneratedSelectRelatedPathKeys as p, index_d_exports as r, CompiledQuery as s, QuerySetState as t, GeneratedHydratedRelationMap as u, MaybeHydratedRelationMap as v, SelectRelatedRelations as w, RelationKeys as x, PrefetchRelatedRelations as y, LookupType as z };
|
|
1310
|
-
//# sourceMappingURL=QuerySetState-
|
|
1312
|
+
//# sourceMappingURL=QuerySetState-C8NgnYTc.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MaterializedModelRecord, n as ModelManager, r as TangoRuntime, t as registerModelObjects } from "./registerModelObjects-
|
|
1
|
+
import { a as MaterializedModelRecord, n as ModelManager, r as TangoRuntime, t as registerModelObjects } from "./registerModelObjects-UMxYImMK.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { Model } from "@danceroutine/tango-schema/domain";
|
|
4
4
|
|
|
@@ -28,4 +28,4 @@ declare global {
|
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
export { resetTangoRuntime as i, getTangoRuntime as n, initializeTangoRuntime as r, index_d_exports as t };
|
|
31
|
-
//# sourceMappingURL=index-
|
|
31
|
+
//# sourceMappingURL=index-O_dY4tRf.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, U as QueryResult, t as QuerySetState } from "./QuerySetState-
|
|
2
|
-
import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "./registerModelObjects-
|
|
1
|
+
import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, U as QueryResult, t as QuerySetState } from "./QuerySetState-C8NgnYTc.js";
|
|
2
|
+
import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "./registerModelObjects-UMxYImMK.js";
|
|
3
3
|
|
|
4
4
|
//#region src/manager/relations/ManyToManyRelatedQuerySet.d.ts
|
|
5
5
|
/**
|
|
@@ -55,6 +55,7 @@ declare class ManyToManyRelatedQuerySet<TTarget extends Record<string, unknown>>
|
|
|
55
55
|
fetch<Out>(shape?: ShapeFunction<TTarget, Out> | ShapeParser<TTarget, Out>): Promise<QueryResult<TTarget | Out>>;
|
|
56
56
|
fetchOne<Out>(shape?: ShapeFunction<TTarget, Out> | ShapeParser<TTarget, Out>): Promise<TTarget | Out | null>;
|
|
57
57
|
count(): Promise<number>;
|
|
58
|
+
exists(): Promise<boolean>;
|
|
58
59
|
protected spawn<TNextBaseResult extends Record<string, unknown>, TNextHydrated extends Record<string, unknown>>(state: QuerySetState<TTarget>): QuerySet<TTarget, TNextBaseResult, unknown, TNextHydrated>;
|
|
59
60
|
private isStateTrivial;
|
|
60
61
|
private scopedState;
|
|
@@ -67,4 +68,4 @@ declare namespace index_d_exports {
|
|
|
67
68
|
}
|
|
68
69
|
//#endregion
|
|
69
70
|
export { ManyToManyRelatedQuerySetBridge as i, index_d_exports$1 as n, ManyToManyRelatedQuerySet as r, index_d_exports as t };
|
|
70
|
-
//# sourceMappingURL=index-
|
|
71
|
+
//# sourceMappingURL=index-d9NRHwNe.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as DBClient } from "./DBClient-DuYcXolQ.js";
|
|
2
2
|
import { i as Dialect, n as AdapterConfig, t as Adapter } from "./Adapter-DKxAaL4l.js";
|
|
3
3
|
import { c as getDefaultAdapterRegistry, l as SqliteAdapter, o as AdapterRegistry, s as connectDB, t as index_d_exports, u as PostgresAdapter } from "./index-o2LFpJ8S.js";
|
|
4
|
-
import { A as QBuilder, E as ManyToManyRelatedManager, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, P as OrderToken, R as FilterKey, U as QueryResult, V as QueryCompiler, c as RelationMeta, i as WhereClause, j as ModelQuerySet, k as index_d_exports$2, n as OrderSpec, o as Direction, s as CompiledQuery, t as QuerySetState, z as LookupType } from "./QuerySetState-
|
|
5
|
-
import { t as index_d_exports$1 } from "./index-
|
|
6
|
-
import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, r as TangoRuntime } from "./registerModelObjects-
|
|
7
|
-
import { i as resetTangoRuntime, n as getTangoRuntime, r as initializeTangoRuntime, t as index_d_exports$3 } from "./index-
|
|
4
|
+
import { A as QBuilder, E as ManyToManyRelatedManager, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, O as ManyToManyTargetRef, P as OrderToken, R as FilterKey, U as QueryResult, V as QueryCompiler, c as RelationMeta, i as WhereClause, j as ModelQuerySet, k as index_d_exports$2, n as OrderSpec, o as Direction, s as CompiledQuery, t as QuerySetState, z as LookupType } from "./QuerySetState-C8NgnYTc.js";
|
|
5
|
+
import { t as index_d_exports$1 } from "./index-d9NRHwNe.js";
|
|
6
|
+
import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, r as TangoRuntime } from "./registerModelObjects-UMxYImMK.js";
|
|
7
|
+
import { i as resetTangoRuntime, n as getTangoRuntime, r as initializeTangoRuntime, t as index_d_exports$3 } from "./index-O_dY4tRf.js";
|
|
8
8
|
import { a as OnCommitOptions, i as AtomicTransaction, n as UnitOfWork, o as SavepointOptions, r as atomic, s as SavepointResult, t as index_d_exports$4 } from "./index-uuG57Y7C.js";
|
|
9
9
|
export { type Adapter, type AdapterConfig, AdapterRegistry, type AtomicTransaction, type CompiledQuery, type DBClient, type Dialect, type Direction, type FilterInput, type FilterKey, type FilterValue, type LookupType, type ManagerLike, ManyToManyRelatedManager, type ManyToManyTargetRef, type MaterializedModelRecord, ModelManager, ModelQuerySet, type OnCommitOptions, type OrderSpec, type OrderToken, PostgresAdapter, QBuilder as Q, QBuilder, type QNode, QueryCompiler, type QueryExecutor, QueryResult, QuerySet, type QuerySetState, type RelationMeta, type SavepointOptions, type SavepointResult, SqliteAdapter, type TableMeta, TangoRuntime, UnitOfWork, type WhereClause, atomic, connectDB, index_d_exports as connection, getDefaultAdapterRegistry, getTangoRuntime, initializeTangoRuntime, index_d_exports$1 as manager, index_d_exports$2 as query, resetTangoRuntime, index_d_exports$3 as runtime, index_d_exports$4 as transaction };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as PostgresAdapter, t as SqliteAdapter } from "./SqliteAdapter-CrUhpTDb.js";
|
|
2
2
|
import { a as connectDB, i as AdapterRegistry, o as getDefaultAdapterRegistry, t as connection_exports } from "./connection-B2cDwZ72.js";
|
|
3
|
-
import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, r as QuerySet, t as query_exports } from "./query-
|
|
4
|
-
import { n as ModelManager, r as ManyToManyRelatedManager } from "./registerModelObjects-
|
|
5
|
-
import { t as manager_exports } from "./manager-
|
|
3
|
+
import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, r as QuerySet, t as query_exports } from "./query-D_93uktq.js";
|
|
4
|
+
import { n as ModelManager, r as ManyToManyRelatedManager } from "./registerModelObjects-41ocGQmv.js";
|
|
5
|
+
import { t as manager_exports } from "./manager-VoPL1sc3.js";
|
|
6
6
|
import { i as TangoRuntime, n as initializeTangoRuntime, r as resetTangoRuntime, t as getTangoRuntime } from "./defaultRuntime-WIsxnh8K.js";
|
|
7
7
|
import { t as runtime_exports } from "./runtime/index.js";
|
|
8
8
|
import { n as UnitOfWork, r as atomic, t as transaction_exports } from "./transaction-DpDXQq5V.js";
|
package/dist/manager/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, O as ManyToManyTargetRef } from "../QuerySetState-
|
|
2
|
-
import { i as ManyToManyRelatedQuerySetBridge, n as index_d_exports, r as ManyToManyRelatedQuerySet } from "../index-
|
|
3
|
-
import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "../registerModelObjects-
|
|
1
|
+
import { D as ManyToManyRelatedManagerCreateInputs, E as ManyToManyRelatedManager, O as ManyToManyTargetRef } from "../QuerySetState-C8NgnYTc.js";
|
|
2
|
+
import { i as ManyToManyRelatedQuerySetBridge, n as index_d_exports, r as ManyToManyRelatedQuerySet } from "../index-d9NRHwNe.js";
|
|
3
|
+
import { a as MaterializedModelRecord, i as ManagerLike, n as ModelManager, t as registerModelObjects } from "../registerModelObjects-UMxYImMK.js";
|
|
4
4
|
export { type ManagerLike, ManyToManyRelatedManager, type ManyToManyRelatedManagerCreateInputs, ManyToManyRelatedQuerySet, type ManyToManyRelatedQuerySetBridge, type ManyToManyTargetRef, type MaterializedModelRecord, ModelManager, registerModelObjects, index_d_exports as relations };
|
package/dist/manager/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "../registerModelObjects-
|
|
2
|
-
import { n as relations_exports } from "../manager-
|
|
1
|
+
import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "../registerModelObjects-41ocGQmv.js";
|
|
2
|
+
import { n as relations_exports } from "../manager-VoPL1sc3.js";
|
|
3
3
|
export { ManyToManyRelatedManager, ManyToManyRelatedQuerySet, ModelManager, registerModelObjects, relations_exports as relations };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-8H4AJuhK.js";
|
|
2
|
-
import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "./registerModelObjects-
|
|
2
|
+
import { i as ManyToManyRelatedQuerySet, n as ModelManager, r as ManyToManyRelatedManager, t as registerModelObjects } from "./registerModelObjects-41ocGQmv.js";
|
|
3
3
|
//#region src/manager/relations/index.ts
|
|
4
4
|
var relations_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
ManyToManyRelatedManager: () => ManyToManyRelatedManager,
|
|
@@ -17,4 +17,4 @@ var manager_exports = /* @__PURE__ */ __exportAll({
|
|
|
17
17
|
//#endregion
|
|
18
18
|
export { relations_exports as n, manager_exports as t };
|
|
19
19
|
|
|
20
|
-
//# sourceMappingURL=manager-
|
|
20
|
+
//# sourceMappingURL=manager-VoPL1sc3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager-
|
|
1
|
+
{"version":3,"file":"manager-VoPL1sc3.js","names":[],"sources":["../src/manager/relations/index.ts","../src/manager/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes ORM relation managers attached to\n * materialized model records.\n */\n\nexport { ManyToManyRelatedQuerySet } from './ManyToManyRelatedQuerySet';\nexport type { ManyToManyRelatedQuerySetBridge } from './ManyToManyRelatedQuerySet';\nexport { ManyToManyRelatedManager } from './ManyToManyRelatedManager';\nexport type { ManyToManyRelatedManagerCreateInputs, ManyToManyTargetRef } from './ManyToManyRelatedManager';\nexport type { MaterializedModelRecord } from './MaterializedModelRecord';\n","/**\n * Domain boundary barrel: centralizes manager-first ORM APIs.\n */\nexport * as relations from './relations/index';\n\nexport type { ManagerLike } from './ManagerLike';\nexport { ModelManager } from './ModelManager';\nexport { registerModelObjects } from './registerModelObjects';\nexport { ManyToManyRelatedQuerySet } from './relations/ManyToManyRelatedQuerySet';\nexport type { ManyToManyRelatedQuerySetBridge } from './relations/ManyToManyRelatedQuerySet';\nexport { ManyToManyRelatedManager } from './relations/ManyToManyRelatedManager';\nexport type { ManyToManyRelatedManagerCreateInputs, ManyToManyTargetRef } from './relations/ManyToManyRelatedManager';\nexport type { MaterializedModelRecord } from './relations/MaterializedModelRecord';\n"],"mappings":""}
|
package/dist/query/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { i as Dialect } from "../Adapter-DKxAaL4l.js";
|
|
2
|
-
import { A as QBuilder, B as index_d_exports, C as ReverseSingleRelations, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, P as OrderToken, R as FilterKey, S as ReverseCollectionRelations, T as SingleRelationHydrationCardinality, U as QueryResult, V as QueryCompiler, _ as ManyRelationHydrationCardinality, a as TableMetaFactory, b as RelationHydrationCardinality, c as RelationMeta, d as GeneratedPrefetchRelatedPathKeys, f as GeneratedRelationFilterKeys, g as InternalRelationHydrationCardinality, h as HydratedRelationMap, i as WhereClause, j as ModelQuerySet, l as ForwardSingleRelations, m as HydratedQueryResult, n as OrderSpec, o as Direction, p as GeneratedSelectRelatedPathKeys, r as index_d_exports$1, s as CompiledQuery, t as QuerySetState, u as GeneratedHydratedRelationMap, v as MaybeHydratedRelationMap, w as SelectRelatedRelations, x as RelationKeys, y as PrefetchRelatedRelations, z as LookupType } from "../QuerySetState-
|
|
2
|
+
import { A as QBuilder, B as index_d_exports, C as ReverseSingleRelations, F as QNode, H as TableMeta, I as FilterInput, L as FilterValue, M as QueryExecutor, N as QuerySet, P as OrderToken, R as FilterKey, S as ReverseCollectionRelations, T as SingleRelationHydrationCardinality, U as QueryResult, V as QueryCompiler, _ as ManyRelationHydrationCardinality, a as TableMetaFactory, b as RelationHydrationCardinality, c as RelationMeta, d as GeneratedPrefetchRelatedPathKeys, f as GeneratedRelationFilterKeys, g as InternalRelationHydrationCardinality, h as HydratedRelationMap, i as WhereClause, j as ModelQuerySet, l as ForwardSingleRelations, m as HydratedQueryResult, n as OrderSpec, o as Direction, p as GeneratedSelectRelatedPathKeys, r as index_d_exports$1, s as CompiledQuery, t as QuerySetState, u as GeneratedHydratedRelationMap, v as MaybeHydratedRelationMap, w as SelectRelatedRelations, x as RelationKeys, y as PrefetchRelatedRelations, z as LookupType } from "../QuerySetState-C8NgnYTc.js";
|
|
3
3
|
export { type CompiledQuery, type Dialect, type Direction, type FilterInput, type FilterKey, type FilterValue, type ForwardSingleRelations, type GeneratedHydratedRelationMap, type GeneratedPrefetchRelatedPathKeys, type GeneratedRelationFilterKeys, type GeneratedSelectRelatedPathKeys, type HydratedQueryResult, type HydratedRelationMap, type InternalRelationHydrationCardinality, type LookupType, type ManyRelationHydrationCardinality, type MaybeHydratedRelationMap, ModelQuerySet, type OrderSpec, type OrderToken, type PrefetchRelatedRelations, QBuilder as Q, QBuilder, type QNode, QueryCompiler, type QueryExecutor, QueryResult, QuerySet, type QuerySetState, type RelationHydrationCardinality, type RelationKeys, type RelationMeta, type ReverseCollectionRelations, type ReverseSingleRelations, type SelectRelatedRelations, type SingleRelationHydrationCardinality, type TableMeta, type TableMetaFactory, type WhereClause, index_d_exports as compiler, index_d_exports$1 as domain };
|
package/dist/query/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, o as domain_exports, r as QuerySet, u as compiler_exports } from "../query-
|
|
1
|
+
import { d as QueryCompiler, i as QBuilder, l as QueryResult, n as ModelQuerySet, o as domain_exports, r as QuerySet, u as compiler_exports } from "../query-D_93uktq.js";
|
|
2
2
|
export { ModelQuerySet, QBuilder as Q, QBuilder, QueryCompiler, QueryResult, QuerySet, compiler_exports as compiler, domain_exports as domain };
|
|
@@ -463,8 +463,9 @@ var QueryCompiler = class QueryCompiler {
|
|
|
463
463
|
].join(", ");
|
|
464
464
|
const whereSQL = whereParts.length ? ` WHERE ${whereParts.join(" AND ")}` : "";
|
|
465
465
|
const orderSQL = ` ORDER BY ${state.order?.length ? state.order.map((order) => `${validatedPlan.orderFields[String(order.by)]} ${order.dir.toUpperCase()}`).join(", ") : `${table}.${validatedPlan.meta.pk} ASC`}`;
|
|
466
|
-
const
|
|
467
|
-
const
|
|
466
|
+
const hasOffset = state.offset !== void 0;
|
|
467
|
+
const limitSQL = state.limit !== void 0 ? ` LIMIT ${state.limit}` : hasOffset && this.adapter.dialect === InternalDialect.SQLITE ? " LIMIT -1" : "";
|
|
468
|
+
const offsetSQL = state.offset !== void 0 ? ` OFFSET ${state.offset}` : "";
|
|
468
469
|
return {
|
|
469
470
|
sql: `SELECT ${select} FROM ${table}${joinCollection.joins.length ? ` ${joinCollection.joins.join(" ")}` : ""}${whereSQL}${orderSQL}${limitSQL}${offsetSQL}`,
|
|
470
471
|
params,
|
|
@@ -476,6 +477,40 @@ var QueryCompiler = class QueryCompiler {
|
|
|
476
477
|
} : void 0
|
|
477
478
|
};
|
|
478
479
|
}
|
|
480
|
+
compileExists(state) {
|
|
481
|
+
const validatedPlan = sqlSafetyAdapter.validate({
|
|
482
|
+
kind: InternalSqlValidationPlanKind.SELECT,
|
|
483
|
+
meta: this.meta,
|
|
484
|
+
selectFields: state.select?.map(String),
|
|
485
|
+
filterKeys: this.collectStateFilterKeys(state),
|
|
486
|
+
orderFields: state.order?.map((order) => String(order.by)),
|
|
487
|
+
relationNames: []
|
|
488
|
+
});
|
|
489
|
+
const table = validatedPlan.meta.table;
|
|
490
|
+
const whereParts = [];
|
|
491
|
+
const params = [];
|
|
492
|
+
if (state.q) {
|
|
493
|
+
const result = this.compileQNode(state.q, params.length + 1, validatedPlan.filterKeys);
|
|
494
|
+
if (result.sql) {
|
|
495
|
+
whereParts.push(result.sql);
|
|
496
|
+
params.push(...result.params);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
state.excludes?.forEach((exclude) => {
|
|
500
|
+
const result = this.compileQNode({
|
|
501
|
+
kind: InternalQNodeType.NOT,
|
|
502
|
+
node: exclude
|
|
503
|
+
}, params.length + 1, validatedPlan.filterKeys);
|
|
504
|
+
if (result.sql) {
|
|
505
|
+
whereParts.push(result.sql);
|
|
506
|
+
params.push(...result.params);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
return {
|
|
510
|
+
sql: `SELECT 1 AS tango_exists FROM ${table}${whereParts.length ? ` WHERE ${whereParts.join(" AND ")}` : ""} LIMIT 1${state.offset ? ` OFFSET ${state.offset}` : ""}`,
|
|
511
|
+
params
|
|
512
|
+
};
|
|
513
|
+
}
|
|
479
514
|
compilePrefetch(node, sourceValues) {
|
|
480
515
|
if (node.throughTable && node.throughSourceKey && node.throughTargetKey) return this.compileManyToManyPrefetch(node, sourceValues);
|
|
481
516
|
const placeholders = this.placeholders.list(sourceValues.length);
|
|
@@ -1128,6 +1163,11 @@ var QuerySet = class QuerySet {
|
|
|
1128
1163
|
};
|
|
1129
1164
|
});
|
|
1130
1165
|
}
|
|
1166
|
+
static validateQueryWindowBound(kind, value) {
|
|
1167
|
+
if (typeof value !== "number") throw new TypeError(`QuerySet.${kind}() expects a number.`);
|
|
1168
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`QuerySet.${kind}() expects a non-negative safe integer.`);
|
|
1169
|
+
return value;
|
|
1170
|
+
}
|
|
1131
1171
|
static invertOrderSpec(order) {
|
|
1132
1172
|
if (!order?.length) return [];
|
|
1133
1173
|
return order.map((spec) => ({
|
|
@@ -1182,7 +1222,7 @@ var QuerySet = class QuerySet {
|
|
|
1182
1222
|
limit(n) {
|
|
1183
1223
|
return this.spawn({
|
|
1184
1224
|
...this.state,
|
|
1185
|
-
limit: n
|
|
1225
|
+
limit: QuerySet.validateQueryWindowBound("limit", n)
|
|
1186
1226
|
});
|
|
1187
1227
|
}
|
|
1188
1228
|
/**
|
|
@@ -1191,7 +1231,7 @@ var QuerySet = class QuerySet {
|
|
|
1191
1231
|
offset(n) {
|
|
1192
1232
|
return this.spawn({
|
|
1193
1233
|
...this.state,
|
|
1194
|
-
offset: n
|
|
1234
|
+
offset: QuerySet.validateQueryWindowBound("offset", n)
|
|
1195
1235
|
});
|
|
1196
1236
|
}
|
|
1197
1237
|
select(fields) {
|
|
@@ -1293,7 +1333,8 @@ var QuerySet = class QuerySet {
|
|
|
1293
1333
|
* Return whether at least one row matches the current query state.
|
|
1294
1334
|
*/
|
|
1295
1335
|
async exists() {
|
|
1296
|
-
|
|
1336
|
+
const compiled = new QueryCompiler(this.executor.meta, this.executor.adapter).compileExists(this.withoutHydrationState());
|
|
1337
|
+
return (await this.executor.client.query(compiled.sql, compiled.params)).rows.length > 0;
|
|
1297
1338
|
}
|
|
1298
1339
|
shapeFetchedRow(row, shape) {
|
|
1299
1340
|
if (!shape) return row;
|
|
@@ -1555,4 +1596,4 @@ var query_exports = /* @__PURE__ */ __exportAll({
|
|
|
1555
1596
|
//#endregion
|
|
1556
1597
|
export { isQNodeLike as a, InternalRelationKind as c, QueryCompiler as d, OrmSqlSafetyAdapter as f, QBuilder as i, QueryResult as l, InternalQNodeType as m, ModelQuerySet as n, domain_exports as o, InternalSqlValidationPlanKind as p, QuerySet as r, TableMetaFactory as s, query_exports as t, compiler_exports as u };
|
|
1557
1598
|
|
|
1558
|
-
//# sourceMappingURL=query-
|
|
1599
|
+
//# sourceMappingURL=query-D_93uktq.js.map
|