@vibeorm/runtime 2.3.0 → 2.3.1
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/adapter-kit/index.js +19 -19
- package/dist/adapter-kit/index.js.map +2 -2
- package/dist/index.js +469 -469
- package/dist/index.js.map +2 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -165,8 +165,8 @@ function compileAdvisoryLock(params) {
|
|
|
165
165
|
}
|
|
166
166
|
const mode = readMode({ value: request.mode, method });
|
|
167
167
|
if (hasSingle) {
|
|
168
|
-
const
|
|
169
|
-
return statementFor({ method, mode, key
|
|
168
|
+
const key = { key: readInt64({ value: request.key, method }) };
|
|
169
|
+
return statementFor({ method, mode, key });
|
|
170
170
|
}
|
|
171
171
|
if (!("classId" in request) || !("objectId" in request)) {
|
|
172
172
|
throw validationError({
|
|
@@ -611,20 +611,20 @@ function wirePlanKey(wire) {
|
|
|
611
611
|
}
|
|
612
612
|
function fieldDecoder(params) {
|
|
613
613
|
const { dialect, field, wire } = params;
|
|
614
|
-
const
|
|
614
|
+
const decode = fieldCodec({ dialect, field }).decode;
|
|
615
615
|
if (isPostgresEnumList({ dialect, field })) {
|
|
616
616
|
return (value) => decodeValue({ dialect, field, value });
|
|
617
617
|
}
|
|
618
|
-
if (
|
|
618
|
+
if (decode === IDENTITY_DECODE)
|
|
619
619
|
return null;
|
|
620
620
|
if (field.isList) {
|
|
621
621
|
if (field.scalarType === "Json" && decodeIsNoop({ scalarType: "Json", wire }))
|
|
622
622
|
return null;
|
|
623
|
-
return (value) => Array.isArray(value) ? value.map((element) => element === null || element === undefined ? element :
|
|
623
|
+
return (value) => Array.isArray(value) ? value.map((element) => element === null || element === undefined ? element : decode(element)) : decode(value);
|
|
624
624
|
}
|
|
625
625
|
if (field.scalarType !== null && decodeIsNoop({ scalarType: field.scalarType, wire }))
|
|
626
626
|
return null;
|
|
627
|
-
return
|
|
627
|
+
return decode;
|
|
628
628
|
}
|
|
629
629
|
function buildDecodePlan(params) {
|
|
630
630
|
const { dialect, model, wire } = params;
|
|
@@ -632,12 +632,12 @@ function buildDecodePlan(params) {
|
|
|
632
632
|
const inPlace = [];
|
|
633
633
|
const renamedColumns = [];
|
|
634
634
|
for (const field of model.fields) {
|
|
635
|
-
const
|
|
636
|
-
byColumn.set(field.columnName, { name: field.name, decode
|
|
635
|
+
const decode = fieldDecoder({ dialect, field, ...wire === undefined ? {} : { wire } });
|
|
636
|
+
byColumn.set(field.columnName, { name: field.name, decode });
|
|
637
637
|
if (field.columnName !== field.name)
|
|
638
638
|
renamedColumns.push(field.columnName);
|
|
639
|
-
if (
|
|
640
|
-
inPlace.push({ column: field.columnName, decode
|
|
639
|
+
if (decode !== null)
|
|
640
|
+
inPlace.push({ column: field.columnName, decode });
|
|
641
641
|
}
|
|
642
642
|
return { byColumn, renamedColumns, decoders: inPlace, inPlace: renamedColumns.length > 0 ? null : inPlace };
|
|
643
643
|
}
|
|
@@ -764,12 +764,12 @@ function getJsonDecodePlan(model) {
|
|
|
764
764
|
const inPlace = [];
|
|
765
765
|
const renamedColumns = [];
|
|
766
766
|
for (const field of model.fields) {
|
|
767
|
-
const
|
|
768
|
-
byColumn.set(field.columnName, { name: field.name, decode
|
|
767
|
+
const decode = field.scalarType === "Json" ? null : field.scalarType === "Bytes" && !field.isList ? decodeBase64Bytes : fieldDecoder({ dialect: "postgres", field });
|
|
768
|
+
byColumn.set(field.columnName, { name: field.name, decode });
|
|
769
769
|
if (field.columnName !== field.name)
|
|
770
770
|
renamedColumns.push(field.columnName);
|
|
771
|
-
if (
|
|
772
|
-
inPlace.push({ column: field.columnName, decode
|
|
771
|
+
if (decode !== null)
|
|
772
|
+
inPlace.push({ column: field.columnName, decode });
|
|
773
773
|
}
|
|
774
774
|
plan = { byColumn, renamedColumns, decoders: inPlace, inPlace: renamedColumns.length > 0 ? null : inPlace };
|
|
775
775
|
jsonDecodePlanCache.set(model, plan);
|
|
@@ -2616,7 +2616,7 @@ function compileOperatorFilter(params) {
|
|
|
2616
2616
|
}
|
|
2617
2617
|
const insensitive = mode === "insensitive";
|
|
2618
2618
|
const strict = mode === "strict";
|
|
2619
|
-
const ciCollated = (
|
|
2619
|
+
const ciCollated = (params) => params.dialect.name === "mysql" && params.field.collation?.toLowerCase().endsWith("_ci") === true;
|
|
2620
2620
|
const requireStringOperand = (operator, operand) => {
|
|
2621
2621
|
if (typeof operand !== "string") {
|
|
2622
2622
|
throw validationError4({
|
|
@@ -2903,13 +2903,13 @@ function compileRelationFilter(params) {
|
|
|
2903
2903
|
meta: { model: model.name, relation: relation.name }
|
|
2904
2904
|
});
|
|
2905
2905
|
}
|
|
2906
|
-
const
|
|
2906
|
+
const conditions = [];
|
|
2907
2907
|
for (const [operator, operand] of Object.entries(value)) {
|
|
2908
2908
|
if (operand === undefined)
|
|
2909
2909
|
continue;
|
|
2910
2910
|
switch (operator) {
|
|
2911
2911
|
case "some":
|
|
2912
|
-
|
|
2912
|
+
conditions.push(buildRelationExists({
|
|
2913
2913
|
ctx,
|
|
2914
2914
|
link,
|
|
2915
2915
|
outer,
|
|
@@ -2917,7 +2917,7 @@ function compileRelationFilter(params) {
|
|
|
2917
2917
|
}));
|
|
2918
2918
|
break;
|
|
2919
2919
|
case "none":
|
|
2920
|
-
|
|
2920
|
+
conditions.push(buildRelationExists({
|
|
2921
2921
|
ctx,
|
|
2922
2922
|
link,
|
|
2923
2923
|
outer,
|
|
@@ -2926,7 +2926,7 @@ function compileRelationFilter(params) {
|
|
|
2926
2926
|
}));
|
|
2927
2927
|
break;
|
|
2928
2928
|
case "every":
|
|
2929
|
-
|
|
2929
|
+
conditions.push(buildRelationExists({
|
|
2930
2930
|
ctx,
|
|
2931
2931
|
link,
|
|
2932
2932
|
outer,
|
|
@@ -2942,15 +2942,15 @@ function compileRelationFilter(params) {
|
|
|
2942
2942
|
});
|
|
2943
2943
|
}
|
|
2944
2944
|
}
|
|
2945
|
-
if (
|
|
2945
|
+
if (conditions.length === 0) {
|
|
2946
2946
|
throw validationError4({
|
|
2947
2947
|
message: `filter on relation ${model.name}.${relation.name} must contain some, every or none`,
|
|
2948
2948
|
meta: { model: model.name, relation: relation.name }
|
|
2949
2949
|
});
|
|
2950
2950
|
}
|
|
2951
|
-
if (
|
|
2952
|
-
return
|
|
2953
|
-
return { kind: "and", operands:
|
|
2951
|
+
if (conditions.length === 1)
|
|
2952
|
+
return conditions[0];
|
|
2953
|
+
return { kind: "and", operands: conditions };
|
|
2954
2954
|
}
|
|
2955
2955
|
let isArm;
|
|
2956
2956
|
let hasIs = false;
|
|
@@ -3145,17 +3145,17 @@ function compileRelationOrderTerms(params) {
|
|
|
3145
3145
|
meta: { model: model.name, relation: relation.name }
|
|
3146
3146
|
});
|
|
3147
3147
|
}
|
|
3148
|
-
const
|
|
3149
|
-
const
|
|
3148
|
+
const direction = requireDirection(value, `orderBy.${relation.name}._count`);
|
|
3149
|
+
const alias = `__ord${++aliasSeq.n}`;
|
|
3150
3150
|
const select = link.kind === "manyToMany" ? {
|
|
3151
3151
|
kind: "select",
|
|
3152
|
-
table: { name: link.join.tableName, alias
|
|
3152
|
+
table: { name: link.join.tableName, alias },
|
|
3153
3153
|
columns: [],
|
|
3154
3154
|
selectExpr: { kind: "countAll" },
|
|
3155
3155
|
where: {
|
|
3156
3156
|
kind: "cmpCol",
|
|
3157
3157
|
op: "eq",
|
|
3158
|
-
left: { table:
|
|
3158
|
+
left: { table: alias, name: link.join.parentColumn },
|
|
3159
3159
|
right: {
|
|
3160
3160
|
table: outer,
|
|
3161
3161
|
name: singleKeyPair({ link, what: "implicit many-to-many ordering" }).parent.columnName
|
|
@@ -3163,12 +3163,12 @@ function compileRelationOrderTerms(params) {
|
|
|
3163
3163
|
}
|
|
3164
3164
|
} : {
|
|
3165
3165
|
kind: "select",
|
|
3166
|
-
table: { name: link.target.tableName, alias
|
|
3166
|
+
table: { name: link.target.tableName, alias },
|
|
3167
3167
|
columns: [],
|
|
3168
3168
|
selectExpr: { kind: "countAll" },
|
|
3169
|
-
where: correlateLink({ link, childTable:
|
|
3169
|
+
where: correlateLink({ link, childTable: alias, outerTable: outer })
|
|
3170
3170
|
};
|
|
3171
|
-
terms.push({ select, direction
|
|
3171
|
+
terms.push({ select, direction });
|
|
3172
3172
|
continue;
|
|
3173
3173
|
}
|
|
3174
3174
|
if (isList) {
|
|
@@ -3576,7 +3576,7 @@ function compileUpdateSet(params) {
|
|
|
3576
3576
|
});
|
|
3577
3577
|
}
|
|
3578
3578
|
if (isPlainObject3(value) && field.scalarType !== "Json") {
|
|
3579
|
-
const entries = Object.entries(value).filter(([,
|
|
3579
|
+
const entries = Object.entries(value).filter(([, operand]) => operand !== undefined);
|
|
3580
3580
|
if (entries.length !== 1) {
|
|
3581
3581
|
throw validationError4({
|
|
3582
3582
|
message: `update of ${model.name}.${field.name} must use exactly one operation`,
|
|
@@ -4134,7 +4134,7 @@ function buildFindShape(params) {
|
|
|
4134
4134
|
},
|
|
4135
4135
|
...where === undefined ? {} : { where }
|
|
4136
4136
|
};
|
|
4137
|
-
const
|
|
4137
|
+
const statement = {
|
|
4138
4138
|
kind: "select",
|
|
4139
4139
|
table: { name: DISTINCT_TABLE_ALIAS },
|
|
4140
4140
|
columns: projectionColumns({ model, selectedFields }),
|
|
@@ -4144,7 +4144,7 @@ function buildFindShape(params) {
|
|
|
4144
4144
|
...limit === undefined ? {} : { limit },
|
|
4145
4145
|
...offset === undefined ? {} : { offset }
|
|
4146
4146
|
};
|
|
4147
|
-
return { statement
|
|
4147
|
+
return { statement, reverseRows: backward, resortBy };
|
|
4148
4148
|
}
|
|
4149
4149
|
if (distinctOuterOrder !== null) {
|
|
4150
4150
|
const inner = {
|
|
@@ -4160,7 +4160,7 @@ function buildFindShape(params) {
|
|
|
4160
4160
|
...projectionColumns({ model, selectedFields }),
|
|
4161
4161
|
...lateralJoins.map((join) => ({ name: join.columnAlias }))
|
|
4162
4162
|
];
|
|
4163
|
-
const
|
|
4163
|
+
const statement = {
|
|
4164
4164
|
kind: "select",
|
|
4165
4165
|
table: { name: DISTINCT_TABLE_ALIAS },
|
|
4166
4166
|
columns: outerColumns,
|
|
@@ -4169,7 +4169,7 @@ function buildFindShape(params) {
|
|
|
4169
4169
|
...limit === undefined ? {} : { limit },
|
|
4170
4170
|
...offset === undefined ? {} : { offset }
|
|
4171
4171
|
};
|
|
4172
|
-
return { statement
|
|
4172
|
+
return { statement, reverseRows: backward, resortBy };
|
|
4173
4173
|
}
|
|
4174
4174
|
const pageFirst = lateralJoins.length > 0 && (limit !== undefined || offset !== undefined) && orderTerms.every((term) => ("column" in term));
|
|
4175
4175
|
if (pageFirst && selection !== undefined) {
|
|
@@ -4185,7 +4185,7 @@ function buildFindShape(params) {
|
|
|
4185
4185
|
...limit === undefined ? {} : { limit },
|
|
4186
4186
|
...offset === undefined ? {} : { offset }
|
|
4187
4187
|
};
|
|
4188
|
-
const
|
|
4188
|
+
const statement = {
|
|
4189
4189
|
kind: "select",
|
|
4190
4190
|
table: { name: model.tableName },
|
|
4191
4191
|
columns,
|
|
@@ -4193,7 +4193,7 @@ function buildFindShape(params) {
|
|
|
4193
4193
|
lateralJoins,
|
|
4194
4194
|
...orderTerms.length === 0 ? {} : { orderBy: orderTerms }
|
|
4195
4195
|
};
|
|
4196
|
-
return { statement
|
|
4196
|
+
return { statement, reverseRows: backward, resortBy };
|
|
4197
4197
|
}
|
|
4198
4198
|
const statement = {
|
|
4199
4199
|
kind: "select",
|
|
@@ -4618,9 +4618,9 @@ function compileGroupByOrder(params) {
|
|
|
4618
4618
|
}
|
|
4619
4619
|
agg = { fn: "countAll" };
|
|
4620
4620
|
} else {
|
|
4621
|
-
const
|
|
4622
|
-
validateAggregatedField({ model, field
|
|
4623
|
-
const aggColumn = key === "_count" ? { name:
|
|
4621
|
+
const field = getFieldMeta({ model, field: selector, context: `orderBy ${name}` });
|
|
4622
|
+
validateAggregatedField({ model, field, key });
|
|
4623
|
+
const aggColumn = key === "_count" ? { name: field.columnName } : compareColumnRef({ dialect, field });
|
|
4624
4624
|
agg = { fn: AGG_FN_BY_KEY[key], column: aggColumn };
|
|
4625
4625
|
}
|
|
4626
4626
|
terms.push({ agg, direction });
|
|
@@ -5070,7 +5070,7 @@ function buildQuery(params) {
|
|
|
5070
5070
|
throw validationError4({ message: "A conflict update requires an explicit target" });
|
|
5071
5071
|
const updates = requireObject({ value: spec.update, what: "onConflict.update", model });
|
|
5072
5072
|
const fields = resolveUpsertUpdateFields({ model, update: Object.keys(updates), targetColumns: new Set(compiled.columns ?? []), skipUpdatedAt: true });
|
|
5073
|
-
const
|
|
5073
|
+
const columns = Object.fromEntries(model.fields.map((field) => [field.name, field.columnName]));
|
|
5074
5074
|
conflictClause = {
|
|
5075
5075
|
columns: compiled.columns ?? [],
|
|
5076
5076
|
...compiled.constraint === undefined ? {} : { constraint: compiled.constraint },
|
|
@@ -5079,7 +5079,7 @@ function buildQuery(params) {
|
|
|
5079
5079
|
const fragment = updates[field.name];
|
|
5080
5080
|
if (!isSqlFragment(fragment))
|
|
5081
5081
|
throw validationError4({ message: "Conflict update expressions must be constructed SQL fragments" });
|
|
5082
|
-
return [field.columnName, mapConflictColumns({ fragment, columns
|
|
5082
|
+
return [field.columnName, mapConflictColumns({ fragment, columns })];
|
|
5083
5083
|
}))
|
|
5084
5084
|
};
|
|
5085
5085
|
} else
|
|
@@ -6981,7 +6981,7 @@ function requirePostgres(params) {
|
|
|
6981
6981
|
return getSqlDialect2({ dialect: params.dialect });
|
|
6982
6982
|
}
|
|
6983
6983
|
async function explainSql(params) {
|
|
6984
|
-
const { executor, sql
|
|
6984
|
+
const { executor, sql, rlsContext } = params;
|
|
6985
6985
|
const mode = params.mode ?? "estimate";
|
|
6986
6986
|
const dialect = requirePostgres({ dialect: params.dialect });
|
|
6987
6987
|
const warnings = [];
|
|
@@ -6998,7 +6998,7 @@ async function explainSql(params) {
|
|
|
6998
6998
|
meta: { mode }
|
|
6999
6999
|
});
|
|
7000
7000
|
}
|
|
7001
|
-
assertExecutableRead({ text:
|
|
7001
|
+
assertExecutableRead({ text: sql.text });
|
|
7002
7002
|
warnings.push("this statement was EXECUTED to produce observed rows and milliseconds; a read-only transaction and a keyword check are not a proof of safety, because a SELECT can call a function with side effects");
|
|
7003
7003
|
}
|
|
7004
7004
|
const contextKeys = rlsContext === undefined ? [] : Object.keys(rlsContext);
|
|
@@ -7014,7 +7014,7 @@ async function explainSql(params) {
|
|
|
7014
7014
|
const report = await explainOnSession({
|
|
7015
7015
|
executor,
|
|
7016
7016
|
dialect: params.dialect,
|
|
7017
|
-
sql
|
|
7017
|
+
sql,
|
|
7018
7018
|
mode,
|
|
7019
7019
|
warnings,
|
|
7020
7020
|
...rlsContext === undefined ? {} : { rlsContext },
|
|
@@ -7033,7 +7033,7 @@ async function explainSql(params) {
|
|
|
7033
7033
|
}
|
|
7034
7034
|
}
|
|
7035
7035
|
async function explainOnSession(params) {
|
|
7036
|
-
const { executor, sql
|
|
7036
|
+
const { executor, sql, mode, rlsContext } = params;
|
|
7037
7037
|
const dialect = requirePostgres({ dialect: params.dialect });
|
|
7038
7038
|
const warnings = params.warnings ?? [];
|
|
7039
7039
|
const contextKeys = rlsContext === undefined ? [] : Object.keys(rlsContext);
|
|
@@ -7061,7 +7061,7 @@ async function explainOnSession(params) {
|
|
|
7061
7061
|
}
|
|
7062
7062
|
const explain = renderPostgresExplain({
|
|
7063
7063
|
dialect,
|
|
7064
|
-
query: { text:
|
|
7064
|
+
query: { text: sql.text, values: [...sql.values], returning: "none" },
|
|
7065
7065
|
options: mode === "analyze" ? { analyze: true, buffers: true } : {}
|
|
7066
7066
|
});
|
|
7067
7067
|
const rows = await run(explain);
|
|
@@ -7288,7 +7288,7 @@ function createStatementDiagnostics(params) {
|
|
|
7288
7288
|
text: query.text,
|
|
7289
7289
|
values: (query.values ?? []).map((value) => Array.isArray(value) ? tx.formatArrayParam(value) : value)
|
|
7290
7290
|
});
|
|
7291
|
-
const
|
|
7291
|
+
const report = await explainOnSession({
|
|
7292
7292
|
executor,
|
|
7293
7293
|
dialect: dialect.name,
|
|
7294
7294
|
sql: { text: statement.text, values: statement.values },
|
|
@@ -7297,11 +7297,11 @@ function createStatementDiagnostics(params) {
|
|
|
7297
7297
|
});
|
|
7298
7298
|
return summarizePlan({
|
|
7299
7299
|
plan: {
|
|
7300
|
-
root:
|
|
7301
|
-
nodeCount:
|
|
7302
|
-
truncated:
|
|
7303
|
-
...
|
|
7304
|
-
...
|
|
7300
|
+
root: report.root,
|
|
7301
|
+
nodeCount: report.nodeCount,
|
|
7302
|
+
truncated: report.truncated,
|
|
7303
|
+
...report.planningTimeMs === undefined ? {} : { planningTimeMs: report.planningTimeMs },
|
|
7304
|
+
...report.executionTimeMs === undefined ? {} : { executionTimeMs: report.executionTimeMs }
|
|
7305
7305
|
},
|
|
7306
7306
|
mode
|
|
7307
7307
|
});
|
|
@@ -7650,13 +7650,13 @@ function recommendFromPlan(params) {
|
|
|
7650
7650
|
candidate: false
|
|
7651
7651
|
});
|
|
7652
7652
|
} else {
|
|
7653
|
-
const
|
|
7653
|
+
const removed = node.rowsRemovedByFilter;
|
|
7654
7654
|
findings.push({
|
|
7655
7655
|
code: "sequential-scan-on-large-table",
|
|
7656
7656
|
severity: "warn",
|
|
7657
7657
|
node: node.nodeType,
|
|
7658
7658
|
relation,
|
|
7659
|
-
evidence: `sequential scan over "${relation}" (about ${facts.estimatedRows} rows, planner cost ${node.estimatedTotalCost} cost units)` + (
|
|
7659
|
+
evidence: `sequential scan over "${relation}" (about ${facts.estimatedRows} rows, planner cost ${node.estimatedTotalCost} cost units)` + (removed === undefined ? "" : `, discarding ${removed} rows by filter`) + (node.actualRows === undefined ? "" : `, returning ${node.actualRows}`),
|
|
7660
7660
|
candidate: true,
|
|
7661
7661
|
indexCandidate: {
|
|
7662
7662
|
table: relation,
|
|
@@ -8207,8 +8207,8 @@ async function loadManyToMany(params) {
|
|
|
8207
8207
|
for (const pair of pairs) {
|
|
8208
8208
|
const rawParent = pair[M2M_PARENT_ALIAS];
|
|
8209
8209
|
delete pair[M2M_PARENT_ALIAS];
|
|
8210
|
-
const
|
|
8211
|
-
const key = relationValueKey({ value:
|
|
8210
|
+
const parentKey = decodeParent === null || rawParent === null || rawParent === undefined ? rawParent : decodeParent(rawParent);
|
|
8211
|
+
const key = relationValueKey({ value: parentKey });
|
|
8212
8212
|
const group = groups.get(key);
|
|
8213
8213
|
if (group === undefined)
|
|
8214
8214
|
groups.set(key, [pair]);
|
|
@@ -8403,10 +8403,10 @@ async function attachLateralRelations(params) {
|
|
|
8403
8403
|
for (const row of rows) {
|
|
8404
8404
|
const raw = row[column];
|
|
8405
8405
|
delete row[column];
|
|
8406
|
-
let
|
|
8406
|
+
let parsed = raw;
|
|
8407
8407
|
if (typeof raw === "string") {
|
|
8408
8408
|
try {
|
|
8409
|
-
|
|
8409
|
+
parsed = JSON.parse(raw);
|
|
8410
8410
|
} catch (cause) {
|
|
8411
8411
|
throw new VibeError19({
|
|
8412
8412
|
code: "VIBE_INTERNAL",
|
|
@@ -8417,10 +8417,10 @@ async function attachLateralRelations(params) {
|
|
|
8417
8417
|
}
|
|
8418
8418
|
}
|
|
8419
8419
|
if (isList) {
|
|
8420
|
-
if (!Array.isArray(
|
|
8420
|
+
if (!Array.isArray(parsed)) {
|
|
8421
8421
|
throw new VibeError19({ code: "VIBE_INTERNAL", message: "to-many relation payload must be an array", meta: { relation: node.name } });
|
|
8422
8422
|
}
|
|
8423
|
-
const children =
|
|
8423
|
+
const children = parsed.map(decodePosition);
|
|
8424
8424
|
for (const child of children) {
|
|
8425
8425
|
for (const name of hiddenOrder)
|
|
8426
8426
|
delete child[name];
|
|
@@ -8428,11 +8428,11 @@ async function attachLateralRelations(params) {
|
|
|
8428
8428
|
row[node.name] = children;
|
|
8429
8429
|
pushAll(kept, children);
|
|
8430
8430
|
} else {
|
|
8431
|
-
if (
|
|
8431
|
+
if (parsed === null) {
|
|
8432
8432
|
row[node.name] = null;
|
|
8433
8433
|
continue;
|
|
8434
8434
|
}
|
|
8435
|
-
const child = decodePosition(
|
|
8435
|
+
const child = decodePosition(parsed);
|
|
8436
8436
|
for (const name of hiddenOrder)
|
|
8437
8437
|
delete child[name];
|
|
8438
8438
|
row[node.name] = child;
|
|
@@ -8497,13 +8497,13 @@ function containsSqlFragment(value, seen = new Set) {
|
|
|
8497
8497
|
return false;
|
|
8498
8498
|
}
|
|
8499
8499
|
function restrictedSqlArgs(params) {
|
|
8500
|
-
const
|
|
8500
|
+
const refuse = () => params.refusal?.() ?? new VibeError20({ code: "VIBE_VALIDATION", message: `SQL fragments are unavailable through ${params.path}; use the unrestricted client`, meta: { path: params.path } });
|
|
8501
8501
|
if (containsSqlFragment(params.value))
|
|
8502
|
-
throw
|
|
8502
|
+
throw refuse();
|
|
8503
8503
|
const seen = new Map;
|
|
8504
8504
|
const copy = (value) => {
|
|
8505
8505
|
if (isSqlFragment2(value))
|
|
8506
|
-
throw
|
|
8506
|
+
throw refuse();
|
|
8507
8507
|
if (typeof value !== "object" || value === null)
|
|
8508
8508
|
return value;
|
|
8509
8509
|
if (seen.has(value))
|
|
@@ -8796,9 +8796,9 @@ function mergeLevel(params) {
|
|
|
8796
8796
|
continue;
|
|
8797
8797
|
}
|
|
8798
8798
|
if (spec === true) {
|
|
8799
|
-
const
|
|
8800
|
-
select[relationName] =
|
|
8801
|
-
relationPlans.set(relationName,
|
|
8799
|
+
const child = mergeLevel({ meta, name, definition, mask: targetMask, args: {} });
|
|
8800
|
+
select[relationName] = child.merged;
|
|
8801
|
+
relationPlans.set(relationName, child.plan);
|
|
8802
8802
|
continue;
|
|
8803
8803
|
}
|
|
8804
8804
|
if (!isPlainObject5(spec)) {
|
|
@@ -9014,12 +9014,12 @@ function validateNestedVerbs(params) {
|
|
|
9014
9014
|
return value;
|
|
9015
9015
|
if (!arms.some((arm) => value[arm] !== undefined))
|
|
9016
9016
|
return one(value);
|
|
9017
|
-
const
|
|
9017
|
+
const next = { ...value };
|
|
9018
9018
|
for (const arm of arms) {
|
|
9019
9019
|
if (value[arm] !== undefined)
|
|
9020
|
-
|
|
9020
|
+
next[arm] = many(value[arm]);
|
|
9021
9021
|
}
|
|
9022
|
-
return
|
|
9022
|
+
return next;
|
|
9023
9023
|
};
|
|
9024
9024
|
const eachBody = (value, arms) => Array.isArray(value) ? value.map((item) => body(item, arms)) : body(value, arms);
|
|
9025
9025
|
const next = { ...verbs };
|
|
@@ -9521,20 +9521,20 @@ function scopeSelection(params) {
|
|
|
9521
9521
|
if (spec === undefined || spec === false)
|
|
9522
9522
|
continue;
|
|
9523
9523
|
if (name === "_count") {
|
|
9524
|
-
const names = spec === true ? model.relations.filter((
|
|
9525
|
-
const entry = spec.select[
|
|
9524
|
+
const names = spec === true ? model.relations.filter((relation) => relation.isList).map((relation) => relation.name) : isPlainObject7(spec) && isPlainObject7(spec.select) ? Object.keys(spec.select).filter((key) => {
|
|
9525
|
+
const entry = spec.select[key];
|
|
9526
9526
|
return entry === true || isPlainObject7(entry);
|
|
9527
9527
|
}) : [];
|
|
9528
9528
|
const countSelect = isPlainObject7(spec) && isPlainObject7(spec.select) ? { ...spec.select } : undefined;
|
|
9529
9529
|
for (const counted of names) {
|
|
9530
|
-
const
|
|
9531
|
-
const
|
|
9532
|
-
if (
|
|
9530
|
+
const relation = model.relationByName.get(counted);
|
|
9531
|
+
const target = relation === undefined ? undefined : meta.modelByName.get(relation.targetModel);
|
|
9532
|
+
if (target?.policy !== undefined) {
|
|
9533
9533
|
throw policyError(`_count of ${model.name}.${counted} cannot enforce @@policy because relation counts take no filter \u2014 use a scoped child count query instead`, { model: model.name, relation: counted });
|
|
9534
9534
|
}
|
|
9535
9535
|
const entry = countSelect?.[counted];
|
|
9536
|
-
if (
|
|
9537
|
-
countSelect[counted] = { ...entry, where: scopeWhere({ meta, model:
|
|
9536
|
+
if (target !== undefined && countSelect !== undefined && isPlainObject7(entry) && entry.where !== undefined) {
|
|
9537
|
+
countSelect[counted] = { ...entry, where: scopeWhere({ meta, model: target, where: entry.where, context }) };
|
|
9538
9538
|
}
|
|
9539
9539
|
}
|
|
9540
9540
|
if (countSelect !== undefined)
|
|
@@ -9627,8 +9627,8 @@ function forceWriteData(params) {
|
|
|
9627
9627
|
}
|
|
9628
9628
|
function forceNestedVerbs(params) {
|
|
9629
9629
|
const { meta, target, verbs, context } = params;
|
|
9630
|
-
const
|
|
9631
|
-
const each = (value, phase) => Array.isArray(value) ? value.map((row) =>
|
|
9630
|
+
const walk = (row, phase) => isPlainObject7(row) ? forceWriteData({ meta, model: target, data: row, context, phase }) : row;
|
|
9631
|
+
const each = (value, phase) => Array.isArray(value) ? value.map((row) => walk(row, phase)) : walk(value, phase);
|
|
9632
9632
|
const body = (value, keys) => {
|
|
9633
9633
|
if (!isPlainObject7(value))
|
|
9634
9634
|
return value;
|
|
@@ -9705,7 +9705,7 @@ function scopedDelegate(params) {
|
|
|
9705
9705
|
const pkWhere = pk.length === 1 ? { [pk[0]]: target[pk[0]] } : { [pkClientKey()]: Object.fromEntries(pk.map((name) => [name, target[name]])) };
|
|
9706
9706
|
return write(raw, pkWhere);
|
|
9707
9707
|
};
|
|
9708
|
-
const
|
|
9708
|
+
const notFound = (method) => new VibeError24({ code: "VIBE_NOT_FOUND", message: `${method} on ${model.name}: no row matches the unique where inside the bound policy context`, meta: { model: model.name, method } });
|
|
9709
9709
|
return {
|
|
9710
9710
|
findMany: (args) => base.findMany(scopeFind(args)),
|
|
9711
9711
|
findFirst: (args) => base.findFirst(scopeFind(args)),
|
|
@@ -9724,9 +9724,9 @@ function scopedDelegate(params) {
|
|
|
9724
9724
|
update: (args) => defer(async (tx) => {
|
|
9725
9725
|
const raw = tx.$bypassPolicy === undefined ? tx : tx.$bypassPolicy();
|
|
9726
9726
|
const data = writeData(args.data, "update");
|
|
9727
|
-
const row = await lockThen(raw, args, (
|
|
9727
|
+
const row = await lockThen(raw, args, (raw, pkWhere) => raw.$models[model.name].update({ ...scopeWrite(args), data, where: pkWhere }));
|
|
9728
9728
|
if (row === null)
|
|
9729
|
-
throw
|
|
9729
|
+
throw notFound("update");
|
|
9730
9730
|
return row;
|
|
9731
9731
|
}),
|
|
9732
9732
|
updateMany: (args) => deferred(() => base.updateMany({
|
|
@@ -9769,16 +9769,16 @@ function scopedDelegate(params) {
|
|
|
9769
9769
|
const update = writeData(args.update, "update");
|
|
9770
9770
|
const create = writeData(args.create, "create");
|
|
9771
9771
|
const projection = scopeWrite(Object.fromEntries(["select", "include"].flatMap((key) => args[key] === undefined ? [] : [[key, args[key]]])));
|
|
9772
|
-
const row = await lockThen(raw, args, (
|
|
9772
|
+
const row = await lockThen(raw, args, (raw, pkWhere) => raw.$models[model.name].update({ ...projection, where: pkWhere, data: update }));
|
|
9773
9773
|
if (row !== null)
|
|
9774
9774
|
return row;
|
|
9775
9775
|
return await raw.$models[model.name].create({ ...projection, data: create });
|
|
9776
9776
|
}),
|
|
9777
9777
|
delete: (args) => defer(async (tx) => {
|
|
9778
9778
|
const raw = tx.$bypassPolicy === undefined ? tx : tx.$bypassPolicy();
|
|
9779
|
-
const row = await lockThen(raw, args, (
|
|
9779
|
+
const row = await lockThen(raw, args, (raw, pkWhere) => raw.$models[model.name].delete({ ...scopeWrite(args), where: pkWhere }));
|
|
9780
9780
|
if (row === null)
|
|
9781
|
-
throw
|
|
9781
|
+
throw notFound("delete");
|
|
9782
9782
|
return row;
|
|
9783
9783
|
}),
|
|
9784
9784
|
deleteMany: (args) => deferred(() => base.deleteMany({
|
|
@@ -10589,7 +10589,7 @@ function walkNestedVerbs(params) {
|
|
|
10589
10589
|
const mode = nestedModeFor(targetEntry);
|
|
10590
10590
|
const out = { ...verbs };
|
|
10591
10591
|
const pred = (verbPath) => requirePred({ ctx, model: target, path: verbPath });
|
|
10592
|
-
const
|
|
10592
|
+
const refuse = (verb, why) => {
|
|
10593
10593
|
throw refusal({
|
|
10594
10594
|
model: target.name,
|
|
10595
10595
|
path: `${path}.${verb}`,
|
|
@@ -10618,7 +10618,7 @@ function walkNestedVerbs(params) {
|
|
|
10618
10618
|
continue;
|
|
10619
10619
|
}
|
|
10620
10620
|
if (scoped && mode === "refuse" && REFERENCE_VERBS2.includes(verb)) {
|
|
10621
|
-
|
|
10621
|
+
refuse(verb, `is disabled \u2014 ${target.name} is configured nested: "refuse"; go through the base client or its own delegate`);
|
|
10622
10622
|
}
|
|
10623
10623
|
switch (verb) {
|
|
10624
10624
|
case "connect":
|
|
@@ -10633,9 +10633,9 @@ function walkNestedVerbs(params) {
|
|
|
10633
10633
|
if (scoped) {
|
|
10634
10634
|
const kind = link().kind;
|
|
10635
10635
|
if (kind === "manyToMany")
|
|
10636
|
-
|
|
10636
|
+
refuse(verb, "clears the whole join set \u2014 unlinking other tenants' rows cannot be verified; disconnect explicit rows instead");
|
|
10637
10637
|
if (!implicitSafe)
|
|
10638
|
-
|
|
10638
|
+
refuse(verb, "first detaches EVERY current child, which cannot be tenant-filtered on this edge; disconnect explicit rows instead");
|
|
10639
10639
|
}
|
|
10640
10640
|
out[verb] = mapItems(operand ?? [], (item) => isPlainObject8(item) ? uniqueWhere(item, verbPath) : item);
|
|
10641
10641
|
break;
|
|
@@ -10646,10 +10646,10 @@ function walkNestedVerbs(params) {
|
|
|
10646
10646
|
const kind = link().kind;
|
|
10647
10647
|
if (kind === "toOneOwner") {
|
|
10648
10648
|
if (tenancyEdge) {
|
|
10649
|
-
|
|
10649
|
+
refuse(verb, "would orphan the row out of its tenant (through-parent set to null) \u2014 delete it or connect a replacement");
|
|
10650
10650
|
}
|
|
10651
10651
|
} else if (!implicitSafe) {
|
|
10652
|
-
|
|
10652
|
+
refuse(verb, "targets whatever row currently points here \u2014 not tenant-verifiable on this edge");
|
|
10653
10653
|
}
|
|
10654
10654
|
}
|
|
10655
10655
|
break;
|
|
@@ -10660,7 +10660,7 @@ function walkNestedVerbs(params) {
|
|
|
10660
10660
|
case "delete": {
|
|
10661
10661
|
if (!relation.isList) {
|
|
10662
10662
|
if (scoped && !implicitSafe) {
|
|
10663
|
-
|
|
10663
|
+
refuse(verb, "targets whatever row is currently connected \u2014 not tenant-verifiable on this edge");
|
|
10664
10664
|
}
|
|
10665
10665
|
break;
|
|
10666
10666
|
}
|
|
@@ -10670,7 +10670,7 @@ function walkNestedVerbs(params) {
|
|
|
10670
10670
|
case "update": {
|
|
10671
10671
|
if (!relation.isList) {
|
|
10672
10672
|
if (scoped && !implicitSafe) {
|
|
10673
|
-
|
|
10673
|
+
refuse(verb, "targets whatever row is currently connected \u2014 not tenant-verifiable on this edge; update it through its own delegate");
|
|
10674
10674
|
}
|
|
10675
10675
|
out[verb] = isPlainObject8(operand) ? "data" in operand && isPlainObject8(operand.data) ? { ...operand, data: walkChildUpdate(operand.data, verbPath) } : walkChildUpdate(operand, verbPath) : operand;
|
|
10676
10676
|
break;
|
|
@@ -10687,7 +10687,7 @@ function walkNestedVerbs(params) {
|
|
|
10687
10687
|
case "upsert": {
|
|
10688
10688
|
if (!relation.isList) {
|
|
10689
10689
|
if (scoped && !implicitSafe) {
|
|
10690
|
-
|
|
10690
|
+
refuse(verb, "updates whatever row is currently connected \u2014 not tenant-verifiable on this edge");
|
|
10691
10691
|
}
|
|
10692
10692
|
out[verb] = isPlainObject8(operand) ? {
|
|
10693
10693
|
...operand,
|
|
@@ -10756,9 +10756,9 @@ function rewriteScopedCall(params) {
|
|
|
10756
10756
|
case "findUniqueOrThrow": {
|
|
10757
10757
|
walkSelection({ ctx, model, args, path: root });
|
|
10758
10758
|
if (!scoped) {
|
|
10759
|
-
const
|
|
10760
|
-
if (
|
|
10761
|
-
args.where =
|
|
10759
|
+
const walked = walkOwnWhere(args.where, `${root}.where`);
|
|
10760
|
+
if (walked !== undefined)
|
|
10761
|
+
args.where = walked;
|
|
10762
10762
|
return { model: model.name, method, args };
|
|
10763
10763
|
}
|
|
10764
10764
|
const flat = isPlainObject8(args.where) ? flattenUniqueWhere({ model, where: args.where }) : args.where;
|
|
@@ -11570,186 +11570,186 @@ class StatementRenderCache {
|
|
|
11570
11570
|
this.entries.set(key, slot);
|
|
11571
11571
|
}
|
|
11572
11572
|
}
|
|
11573
|
-
function addIdent(
|
|
11574
|
-
|
|
11573
|
+
function addIdent(walk, name) {
|
|
11574
|
+
walk.key += `\xA7${name.length}~${name}`;
|
|
11575
11575
|
}
|
|
11576
|
-
function addCol(
|
|
11576
|
+
function addCol(walk, column) {
|
|
11577
11577
|
if (column.table !== undefined)
|
|
11578
|
-
addIdent(
|
|
11579
|
-
|
|
11580
|
-
addIdent(
|
|
11578
|
+
addIdent(walk, column.table);
|
|
11579
|
+
walk.key += ".";
|
|
11580
|
+
addIdent(walk, column.name);
|
|
11581
11581
|
if (column.transform !== undefined)
|
|
11582
|
-
|
|
11582
|
+
walk.key += column.transform === "castText" ? "^t" : "^b";
|
|
11583
11583
|
if (column.castReal === true)
|
|
11584
|
-
|
|
11584
|
+
walk.key += "^r";
|
|
11585
11585
|
if (column.alias !== undefined) {
|
|
11586
|
-
|
|
11587
|
-
addIdent(
|
|
11586
|
+
walk.key += "^a";
|
|
11587
|
+
addIdent(walk, column.alias);
|
|
11588
11588
|
}
|
|
11589
11589
|
}
|
|
11590
|
-
function addTable(
|
|
11591
|
-
addIdent(
|
|
11590
|
+
function addTable(walk, table) {
|
|
11591
|
+
addIdent(walk, table.name);
|
|
11592
11592
|
if (table.alias !== undefined) {
|
|
11593
|
-
|
|
11594
|
-
addIdent(
|
|
11593
|
+
walk.key += "@";
|
|
11594
|
+
addIdent(walk, table.alias);
|
|
11595
11595
|
}
|
|
11596
11596
|
}
|
|
11597
|
-
function addAgg(
|
|
11598
|
-
|
|
11597
|
+
function addAgg(walk, agg) {
|
|
11598
|
+
walk.key += agg.fn;
|
|
11599
11599
|
if (agg.fn !== "countAll")
|
|
11600
|
-
addCol(
|
|
11600
|
+
addCol(walk, agg.column);
|
|
11601
11601
|
}
|
|
11602
|
-
function addSetEntry(
|
|
11602
|
+
function addSetEntry(walk, name, value) {
|
|
11603
11603
|
if (isJsonParamCell(value)) {
|
|
11604
|
-
|
|
11605
|
-
addIdent(
|
|
11606
|
-
|
|
11604
|
+
walk.key += "=j";
|
|
11605
|
+
addIdent(walk, name);
|
|
11606
|
+
walk.values.push(value.text);
|
|
11607
11607
|
return;
|
|
11608
11608
|
}
|
|
11609
11609
|
if (isSetOperation(value)) {
|
|
11610
|
-
|
|
11611
|
-
addIdent(
|
|
11612
|
-
|
|
11610
|
+
walk.key += `=o${value.__op}`;
|
|
11611
|
+
addIdent(walk, name);
|
|
11612
|
+
walk.values.push(value.value);
|
|
11613
11613
|
return;
|
|
11614
11614
|
}
|
|
11615
11615
|
if (isDbNowMarker(value)) {
|
|
11616
|
-
|
|
11617
|
-
addIdent(
|
|
11616
|
+
walk.key += value.offsetSeconds === 0 ? "=N0" : "=N1";
|
|
11617
|
+
addIdent(walk, name);
|
|
11618
11618
|
if (value.offsetSeconds !== 0)
|
|
11619
|
-
|
|
11619
|
+
walk.values.push(value.offsetSeconds);
|
|
11620
11620
|
return;
|
|
11621
11621
|
}
|
|
11622
11622
|
if (isListSetOperation(value)) {
|
|
11623
|
-
|
|
11624
|
-
addIdent(
|
|
11625
|
-
|
|
11623
|
+
walk.key += `=l${value.__listOp}`;
|
|
11624
|
+
addIdent(walk, name);
|
|
11625
|
+
walk.values.push(value.value);
|
|
11626
11626
|
return;
|
|
11627
11627
|
}
|
|
11628
|
-
|
|
11629
|
-
addIdent(
|
|
11630
|
-
|
|
11628
|
+
walk.key += "=v";
|
|
11629
|
+
addIdent(walk, name);
|
|
11630
|
+
walk.values.push(value);
|
|
11631
11631
|
}
|
|
11632
|
-
function addReturning(
|
|
11632
|
+
function addReturning(walk, returning) {
|
|
11633
11633
|
if (returning === undefined || returning.length === 0) {
|
|
11634
|
-
|
|
11634
|
+
walk.key += "r0";
|
|
11635
11635
|
return;
|
|
11636
11636
|
}
|
|
11637
|
-
|
|
11637
|
+
walk.key += "r(";
|
|
11638
11638
|
for (const name of returning)
|
|
11639
|
-
addIdent(
|
|
11640
|
-
|
|
11639
|
+
addIdent(walk, name);
|
|
11640
|
+
walk.key += ")";
|
|
11641
11641
|
}
|
|
11642
|
-
function walkExpr(
|
|
11642
|
+
function walkExpr(walk, dialect, expr) {
|
|
11643
11643
|
switch (expr.kind) {
|
|
11644
11644
|
case "cmp":
|
|
11645
11645
|
if (isDbNowMarker(expr.value)) {
|
|
11646
|
-
|
|
11647
|
-
addCol(
|
|
11646
|
+
walk.key += `cN${expr.op}${expr.value.offsetSeconds === 0 ? "0" : "1"}`;
|
|
11647
|
+
addCol(walk, expr.column);
|
|
11648
11648
|
if (expr.value.offsetSeconds !== 0)
|
|
11649
|
-
|
|
11649
|
+
walk.values.push(expr.value.offsetSeconds);
|
|
11650
11650
|
return true;
|
|
11651
11651
|
}
|
|
11652
|
-
|
|
11653
|
-
addCol(
|
|
11654
|
-
|
|
11652
|
+
walk.key += `c${expr.op}`;
|
|
11653
|
+
addCol(walk, expr.column);
|
|
11654
|
+
walk.values.push(expr.value);
|
|
11655
11655
|
return true;
|
|
11656
11656
|
case "cmpCol":
|
|
11657
|
-
|
|
11658
|
-
addCol(
|
|
11659
|
-
addCol(
|
|
11657
|
+
walk.key += `k${expr.op}`;
|
|
11658
|
+
addCol(walk, expr.left);
|
|
11659
|
+
addCol(walk, expr.right);
|
|
11660
11660
|
return true;
|
|
11661
11661
|
case "isNull":
|
|
11662
|
-
|
|
11663
|
-
addCol(
|
|
11662
|
+
walk.key += expr.negate === true ? "n1" : "n0";
|
|
11663
|
+
addCol(walk, expr.column);
|
|
11664
11664
|
return true;
|
|
11665
11665
|
case "inArray": {
|
|
11666
11666
|
if (expr.values.length === 0) {
|
|
11667
|
-
|
|
11667
|
+
walk.key += expr.negate === true ? "z1" : "z0";
|
|
11668
11668
|
return true;
|
|
11669
11669
|
}
|
|
11670
|
-
|
|
11671
|
-
addCol(
|
|
11670
|
+
walk.key += expr.negate === true ? "i1" : "i0";
|
|
11671
|
+
addCol(walk, expr.column);
|
|
11672
11672
|
if (dialect.inArrayStrategy === "any") {
|
|
11673
|
-
|
|
11673
|
+
walk.values.push([...expr.values]);
|
|
11674
11674
|
} else {
|
|
11675
|
-
|
|
11675
|
+
walk.key += `#${expr.values.length}`;
|
|
11676
11676
|
for (const value of expr.values)
|
|
11677
|
-
|
|
11677
|
+
walk.values.push(value);
|
|
11678
11678
|
}
|
|
11679
11679
|
return true;
|
|
11680
11680
|
}
|
|
11681
11681
|
case "tupleIn": {
|
|
11682
11682
|
if (expr.columns.length === 0)
|
|
11683
11683
|
return false;
|
|
11684
|
-
|
|
11684
|
+
walk.key += `Tu${expr.negate === true ? "1" : "0"}${expr.columns.length}#${expr.rows.length}(`;
|
|
11685
11685
|
for (const column of expr.columns)
|
|
11686
|
-
addCol(
|
|
11687
|
-
|
|
11686
|
+
addCol(walk, column);
|
|
11687
|
+
walk.key += ")";
|
|
11688
11688
|
if (expr.rows.length === 0)
|
|
11689
11689
|
return true;
|
|
11690
11690
|
for (const row of expr.rows) {
|
|
11691
11691
|
if (row.length !== expr.columns.length)
|
|
11692
11692
|
return false;
|
|
11693
11693
|
for (const value of row)
|
|
11694
|
-
|
|
11694
|
+
walk.values.push(value);
|
|
11695
11695
|
}
|
|
11696
11696
|
return true;
|
|
11697
11697
|
}
|
|
11698
11698
|
case "like":
|
|
11699
|
-
|
|
11700
|
-
addCol(
|
|
11701
|
-
|
|
11699
|
+
walk.key += `L${expr.insensitive === true ? "i" : "s"}${expr.negate === true ? "n" : "p"}`;
|
|
11700
|
+
addCol(walk, expr.column);
|
|
11701
|
+
walk.values.push(expr.pattern);
|
|
11702
11702
|
return true;
|
|
11703
11703
|
case "strictMatch":
|
|
11704
|
-
|
|
11705
|
-
addCol(
|
|
11706
|
-
|
|
11704
|
+
walk.key += `S${expr.op}${expr.negate === true ? "n" : "p"}`;
|
|
11705
|
+
addCol(walk, expr.column);
|
|
11706
|
+
walk.values.push(expr.op === "equals" ? expr.value : strictMatchPattern({ strategy: dialect.strictMatchStrategy, op: expr.op, value: expr.value }));
|
|
11707
11707
|
return true;
|
|
11708
11708
|
case "and":
|
|
11709
11709
|
case "or": {
|
|
11710
|
-
|
|
11710
|
+
walk.key += `${expr.kind === "and" ? "A" : "O"}${expr.operands.length}(`;
|
|
11711
11711
|
for (const operand of expr.operands) {
|
|
11712
|
-
if (!walkExpr(
|
|
11712
|
+
if (!walkExpr(walk, dialect, operand))
|
|
11713
11713
|
return false;
|
|
11714
11714
|
}
|
|
11715
|
-
|
|
11715
|
+
walk.key += ")";
|
|
11716
11716
|
return true;
|
|
11717
11717
|
}
|
|
11718
11718
|
case "not":
|
|
11719
|
-
|
|
11720
|
-
if (!walkExpr(
|
|
11719
|
+
walk.key += "!(";
|
|
11720
|
+
if (!walkExpr(walk, dialect, expr.operand))
|
|
11721
11721
|
return false;
|
|
11722
|
-
|
|
11722
|
+
walk.key += ")";
|
|
11723
11723
|
return true;
|
|
11724
11724
|
case "exists":
|
|
11725
|
-
|
|
11726
|
-
if (!walkSelect(
|
|
11725
|
+
walk.key += expr.negate === true ? "E1(" : "E0(";
|
|
11726
|
+
if (!walkSelect(walk, dialect, expr.select))
|
|
11727
11727
|
return false;
|
|
11728
|
-
|
|
11728
|
+
walk.key += ")";
|
|
11729
11729
|
return true;
|
|
11730
11730
|
case "aggCmp":
|
|
11731
|
-
|
|
11732
|
-
addAgg(
|
|
11733
|
-
|
|
11731
|
+
walk.key += `g${expr.op}`;
|
|
11732
|
+
addAgg(walk, expr.agg);
|
|
11733
|
+
walk.values.push(expr.value);
|
|
11734
11734
|
return true;
|
|
11735
11735
|
case "arrayHas":
|
|
11736
|
-
|
|
11737
|
-
addCol(
|
|
11738
|
-
|
|
11736
|
+
walk.key += expr.negate === true ? "h1" : "h0";
|
|
11737
|
+
addCol(walk, expr.column);
|
|
11738
|
+
walk.values.push(expr.value);
|
|
11739
11739
|
return true;
|
|
11740
11740
|
case "arrayContainsAll":
|
|
11741
|
-
|
|
11742
|
-
addCol(
|
|
11743
|
-
|
|
11741
|
+
walk.key += "H";
|
|
11742
|
+
addCol(walk, expr.column);
|
|
11743
|
+
walk.values.push([...expr.values]);
|
|
11744
11744
|
return true;
|
|
11745
11745
|
case "arrayOverlaps":
|
|
11746
|
-
|
|
11747
|
-
addCol(
|
|
11748
|
-
|
|
11746
|
+
walk.key += "V";
|
|
11747
|
+
addCol(walk, expr.column);
|
|
11748
|
+
walk.values.push([...expr.values]);
|
|
11749
11749
|
return true;
|
|
11750
11750
|
case "arrayIsEmpty":
|
|
11751
|
-
|
|
11752
|
-
addCol(
|
|
11751
|
+
walk.key += expr.empty ? "e1" : "e0";
|
|
11752
|
+
addCol(walk, expr.column);
|
|
11753
11753
|
return true;
|
|
11754
11754
|
case "jsonFilter":
|
|
11755
11755
|
return false;
|
|
@@ -11757,140 +11757,140 @@ function walkExpr(walk2, dialect, expr) {
|
|
|
11757
11757
|
case "fragment":
|
|
11758
11758
|
return false;
|
|
11759
11759
|
case "raw":
|
|
11760
|
-
|
|
11761
|
-
addIdent(
|
|
11762
|
-
|
|
11760
|
+
walk.key += "R(";
|
|
11761
|
+
addIdent(walk, expr.text);
|
|
11762
|
+
walk.key += ")";
|
|
11763
11763
|
return true;
|
|
11764
11764
|
}
|
|
11765
11765
|
}
|
|
11766
|
-
function walkOrderTerm2(
|
|
11766
|
+
function walkOrderTerm2(walk, dialect, term) {
|
|
11767
11767
|
if ("agg" in term) {
|
|
11768
|
-
|
|
11769
|
-
addAgg(
|
|
11768
|
+
walk.key += "a";
|
|
11769
|
+
addAgg(walk, term.agg);
|
|
11770
11770
|
} else if ("select" in term) {
|
|
11771
|
-
|
|
11772
|
-
if (!walkSelect(
|
|
11771
|
+
walk.key += "q(";
|
|
11772
|
+
if (!walkSelect(walk, dialect, term.select))
|
|
11773
11773
|
return false;
|
|
11774
|
-
|
|
11774
|
+
walk.key += ")";
|
|
11775
11775
|
} else {
|
|
11776
|
-
addCol(
|
|
11777
|
-
|
|
11776
|
+
addCol(walk, term.column);
|
|
11777
|
+
walk.key += term.nulls === undefined ? "-" : term.nulls === "first" ? "^" : "$";
|
|
11778
11778
|
}
|
|
11779
|
-
|
|
11779
|
+
walk.key += term.direction === "asc" ? "+" : "~";
|
|
11780
11780
|
return true;
|
|
11781
11781
|
}
|
|
11782
|
-
function walkSelect(
|
|
11783
|
-
|
|
11782
|
+
function walkSelect(walk, dialect, statement) {
|
|
11783
|
+
walk.key += "S{";
|
|
11784
11784
|
if (statement.distinctOn !== undefined && statement.distinctOn.length > 0) {
|
|
11785
|
-
|
|
11785
|
+
walk.key += "d(";
|
|
11786
11786
|
for (const column of statement.distinctOn)
|
|
11787
|
-
addCol(
|
|
11788
|
-
|
|
11787
|
+
addCol(walk, column);
|
|
11788
|
+
walk.key += ")";
|
|
11789
11789
|
}
|
|
11790
|
-
|
|
11790
|
+
walk.key += "p(";
|
|
11791
11791
|
for (const column of statement.columns)
|
|
11792
|
-
addCol(
|
|
11793
|
-
|
|
11792
|
+
addCol(walk, column);
|
|
11793
|
+
walk.key += ")";
|
|
11794
11794
|
if (statement.selectExpr !== undefined) {
|
|
11795
11795
|
if (statement.selectExpr.kind === "one") {
|
|
11796
|
-
|
|
11796
|
+
walk.key += "x1";
|
|
11797
11797
|
} else {
|
|
11798
|
-
|
|
11798
|
+
walk.key += "xc";
|
|
11799
11799
|
if (statement.selectExpr.alias !== undefined)
|
|
11800
|
-
addIdent(
|
|
11800
|
+
addIdent(walk, statement.selectExpr.alias);
|
|
11801
11801
|
}
|
|
11802
11802
|
}
|
|
11803
11803
|
if (statement.aggregates !== undefined) {
|
|
11804
11804
|
for (const selection of statement.aggregates) {
|
|
11805
|
-
|
|
11806
|
-
addAgg(
|
|
11807
|
-
addIdent(
|
|
11805
|
+
walk.key += "a";
|
|
11806
|
+
addAgg(walk, selection.agg);
|
|
11807
|
+
addIdent(walk, selection.alias);
|
|
11808
11808
|
}
|
|
11809
11809
|
}
|
|
11810
11810
|
if (statement.rowNumber !== undefined) {
|
|
11811
|
-
|
|
11811
|
+
walk.key += "W(";
|
|
11812
11812
|
for (const column of statement.rowNumber.partitionBy)
|
|
11813
|
-
addCol(
|
|
11814
|
-
|
|
11813
|
+
addCol(walk, column);
|
|
11814
|
+
walk.key += ":";
|
|
11815
11815
|
for (const term of statement.rowNumber.orderBy) {
|
|
11816
|
-
if (!walkOrderTerm2(
|
|
11816
|
+
if (!walkOrderTerm2(walk, dialect, term))
|
|
11817
11817
|
return false;
|
|
11818
11818
|
}
|
|
11819
|
-
addIdent(
|
|
11820
|
-
|
|
11819
|
+
addIdent(walk, statement.rowNumber.alias);
|
|
11820
|
+
walk.key += ")";
|
|
11821
11821
|
}
|
|
11822
|
-
|
|
11823
|
-
addTable(
|
|
11822
|
+
walk.key += "f";
|
|
11823
|
+
addTable(walk, statement.table);
|
|
11824
11824
|
if (statement.fromSelect !== undefined) {
|
|
11825
|
-
|
|
11826
|
-
if (!walkSelect(
|
|
11825
|
+
walk.key += "F(";
|
|
11826
|
+
if (!walkSelect(walk, dialect, statement.fromSelect))
|
|
11827
11827
|
return false;
|
|
11828
|
-
|
|
11828
|
+
walk.key += ")";
|
|
11829
11829
|
}
|
|
11830
11830
|
if (statement.innerJoins !== undefined && statement.innerJoins.length > 0) {
|
|
11831
11831
|
for (const join of statement.innerJoins) {
|
|
11832
|
-
|
|
11833
|
-
addTable(
|
|
11832
|
+
walk.key += "J(";
|
|
11833
|
+
addTable(walk, join.table);
|
|
11834
11834
|
for (const pair of join.on) {
|
|
11835
|
-
addCol(
|
|
11836
|
-
|
|
11837
|
-
addCol(
|
|
11835
|
+
addCol(walk, pair.left);
|
|
11836
|
+
walk.key += "=";
|
|
11837
|
+
addCol(walk, pair.right);
|
|
11838
11838
|
}
|
|
11839
|
-
|
|
11839
|
+
walk.key += ")";
|
|
11840
11840
|
}
|
|
11841
11841
|
}
|
|
11842
11842
|
if (statement.lateralJoins !== undefined && statement.lateralJoins.length > 0) {
|
|
11843
11843
|
for (const join of statement.lateralJoins) {
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
if (!walkSelect(
|
|
11844
|
+
walk.key += join.agg === "count" ? "Jc(" : join.agg === "jsonArray" ? "Ja(" : "Jo(";
|
|
11845
|
+
walk.key += join.rowFormat === "positional" ? "pos;" : "obj;";
|
|
11846
|
+
if (!walkSelect(walk, dialect, join.select))
|
|
11847
11847
|
return false;
|
|
11848
|
-
addIdent(
|
|
11849
|
-
addIdent(
|
|
11850
|
-
|
|
11848
|
+
addIdent(walk, join.columnAlias);
|
|
11849
|
+
addIdent(walk, join.alias);
|
|
11850
|
+
walk.key += ")";
|
|
11851
11851
|
}
|
|
11852
11852
|
}
|
|
11853
11853
|
if (statement.where !== undefined) {
|
|
11854
|
-
|
|
11855
|
-
if (!walkExpr(
|
|
11854
|
+
walk.key += "w";
|
|
11855
|
+
if (!walkExpr(walk, dialect, statement.where))
|
|
11856
11856
|
return false;
|
|
11857
11857
|
}
|
|
11858
11858
|
if (statement.groupBy !== undefined && statement.groupBy.length > 0) {
|
|
11859
|
-
|
|
11859
|
+
walk.key += "b(";
|
|
11860
11860
|
for (const column of statement.groupBy)
|
|
11861
|
-
addCol(
|
|
11862
|
-
|
|
11861
|
+
addCol(walk, column);
|
|
11862
|
+
walk.key += ")";
|
|
11863
11863
|
}
|
|
11864
11864
|
if (statement.having !== undefined) {
|
|
11865
|
-
|
|
11866
|
-
if (!walkExpr(
|
|
11865
|
+
walk.key += "v";
|
|
11866
|
+
if (!walkExpr(walk, dialect, statement.having))
|
|
11867
11867
|
return false;
|
|
11868
11868
|
}
|
|
11869
11869
|
if (statement.orderBy !== undefined && statement.orderBy.length > 0) {
|
|
11870
|
-
|
|
11870
|
+
walk.key += "o(";
|
|
11871
11871
|
for (const term of statement.orderBy) {
|
|
11872
|
-
if (!walkOrderTerm2(
|
|
11872
|
+
if (!walkOrderTerm2(walk, dialect, term))
|
|
11873
11873
|
return false;
|
|
11874
11874
|
}
|
|
11875
|
-
|
|
11875
|
+
walk.key += ")";
|
|
11876
11876
|
}
|
|
11877
11877
|
if (statement.limit !== undefined)
|
|
11878
|
-
|
|
11878
|
+
walk.key += `t${statement.limit}`;
|
|
11879
11879
|
if (statement.offset !== undefined)
|
|
11880
|
-
|
|
11880
|
+
walk.key += `s${statement.offset}`;
|
|
11881
11881
|
if (statement.rowLock !== undefined) {
|
|
11882
|
-
|
|
11882
|
+
walk.key += `u:${statement.rowLock.strength}/${statement.rowLock.wait}`;
|
|
11883
11883
|
}
|
|
11884
|
-
|
|
11884
|
+
walk.key += "}";
|
|
11885
11885
|
return true;
|
|
11886
11886
|
}
|
|
11887
|
-
function walkInsert(
|
|
11888
|
-
|
|
11889
|
-
addTable(
|
|
11890
|
-
|
|
11887
|
+
function walkInsert(walk, dialect, statement) {
|
|
11888
|
+
walk.key += "I{";
|
|
11889
|
+
addTable(walk, statement.table);
|
|
11890
|
+
walk.key += "c(";
|
|
11891
11891
|
for (const name of statement.columns)
|
|
11892
|
-
addIdent(
|
|
11893
|
-
|
|
11892
|
+
addIdent(walk, name);
|
|
11893
|
+
walk.key += `)r${statement.rows.length}`;
|
|
11894
11894
|
const arity = statement.columns.length;
|
|
11895
11895
|
for (let rowIndex = 0;rowIndex < statement.rows.length; rowIndex++) {
|
|
11896
11896
|
const row = statement.rows[rowIndex];
|
|
@@ -11899,95 +11899,95 @@ function walkInsert(walk2, dialect, statement) {
|
|
|
11899
11899
|
for (let cell = 0;cell < row.length; cell++) {
|
|
11900
11900
|
const value = row[cell];
|
|
11901
11901
|
if (isSqlDefaultCell(value))
|
|
11902
|
-
|
|
11902
|
+
walk.key += `D${rowIndex}:${cell};`;
|
|
11903
11903
|
else if (isJsonParamCell(value)) {
|
|
11904
|
-
|
|
11905
|
-
|
|
11904
|
+
walk.key += `J${rowIndex}:${cell};`;
|
|
11905
|
+
walk.values.push(value.text);
|
|
11906
11906
|
} else if (isDbNowMarker(value)) {
|
|
11907
|
-
|
|
11907
|
+
walk.key += `T${rowIndex}:${cell}:${value.offsetSeconds === 0 ? "0" : "1"};`;
|
|
11908
11908
|
if (value.offsetSeconds !== 0)
|
|
11909
|
-
|
|
11909
|
+
walk.values.push(value.offsetSeconds);
|
|
11910
11910
|
} else
|
|
11911
|
-
|
|
11911
|
+
walk.values.push(value);
|
|
11912
11912
|
}
|
|
11913
11913
|
}
|
|
11914
11914
|
const onConflict = statement.onConflict;
|
|
11915
11915
|
if (onConflict !== undefined) {
|
|
11916
11916
|
if ("doNothing" in onConflict) {
|
|
11917
|
-
|
|
11917
|
+
walk.key += "N(";
|
|
11918
11918
|
if (onConflict.constraint !== undefined) {
|
|
11919
|
-
|
|
11920
|
-
addIdent(
|
|
11919
|
+
walk.key += "K";
|
|
11920
|
+
addIdent(walk, onConflict.constraint);
|
|
11921
11921
|
}
|
|
11922
11922
|
if (onConflict.columns !== undefined) {
|
|
11923
11923
|
for (const name of onConflict.columns)
|
|
11924
|
-
addIdent(
|
|
11924
|
+
addIdent(walk, name);
|
|
11925
11925
|
}
|
|
11926
11926
|
if (onConflict.conflictWhere !== undefined) {
|
|
11927
|
-
|
|
11928
|
-
addIdent(
|
|
11927
|
+
walk.key += "w";
|
|
11928
|
+
addIdent(walk, onConflict.conflictWhere);
|
|
11929
11929
|
}
|
|
11930
|
-
|
|
11930
|
+
walk.key += ")";
|
|
11931
11931
|
} else {
|
|
11932
11932
|
if (Object.values(onConflict.update).some(isSqlFragment3))
|
|
11933
11933
|
return false;
|
|
11934
|
-
|
|
11934
|
+
walk.key += "U(";
|
|
11935
11935
|
if (onConflict.constraint !== undefined) {
|
|
11936
|
-
|
|
11937
|
-
addIdent(
|
|
11936
|
+
walk.key += "K";
|
|
11937
|
+
addIdent(walk, onConflict.constraint);
|
|
11938
11938
|
}
|
|
11939
11939
|
for (const name of onConflict.columns)
|
|
11940
|
-
addIdent(
|
|
11941
|
-
|
|
11940
|
+
addIdent(walk, name);
|
|
11941
|
+
walk.key += ":";
|
|
11942
11942
|
for (const [name, value] of Object.entries(onConflict.update))
|
|
11943
|
-
addSetEntry(
|
|
11943
|
+
addSetEntry(walk, name, value);
|
|
11944
11944
|
if (onConflict.lastInsertIdColumn !== undefined) {
|
|
11945
|
-
|
|
11946
|
-
addIdent(
|
|
11945
|
+
walk.key += "@";
|
|
11946
|
+
addIdent(walk, onConflict.lastInsertIdColumn);
|
|
11947
11947
|
}
|
|
11948
|
-
|
|
11948
|
+
walk.key += ")";
|
|
11949
11949
|
}
|
|
11950
11950
|
}
|
|
11951
|
-
addReturning(
|
|
11952
|
-
|
|
11951
|
+
addReturning(walk, statement.returning);
|
|
11952
|
+
walk.key += "}";
|
|
11953
11953
|
return true;
|
|
11954
11954
|
}
|
|
11955
|
-
function walkUpdate(
|
|
11956
|
-
|
|
11957
|
-
addTable(
|
|
11955
|
+
function walkUpdate(walk, dialect, statement) {
|
|
11956
|
+
walk.key += "U{";
|
|
11957
|
+
addTable(walk, statement.table);
|
|
11958
11958
|
for (const [name, value] of Object.entries(statement.set))
|
|
11959
|
-
addSetEntry(
|
|
11959
|
+
addSetEntry(walk, name, value);
|
|
11960
11960
|
if (statement.where !== undefined) {
|
|
11961
|
-
|
|
11962
|
-
if (!walkExpr(
|
|
11961
|
+
walk.key += "w";
|
|
11962
|
+
if (!walkExpr(walk, dialect, statement.where))
|
|
11963
11963
|
return false;
|
|
11964
11964
|
}
|
|
11965
|
-
addReturning(
|
|
11966
|
-
|
|
11965
|
+
addReturning(walk, statement.returning);
|
|
11966
|
+
walk.key += "}";
|
|
11967
11967
|
return true;
|
|
11968
11968
|
}
|
|
11969
|
-
function walkDelete(
|
|
11970
|
-
|
|
11971
|
-
addTable(
|
|
11969
|
+
function walkDelete(walk, dialect, statement) {
|
|
11970
|
+
walk.key += "D{";
|
|
11971
|
+
addTable(walk, statement.table);
|
|
11972
11972
|
if (statement.where !== undefined) {
|
|
11973
|
-
|
|
11974
|
-
if (!walkExpr(
|
|
11973
|
+
walk.key += "w";
|
|
11974
|
+
if (!walkExpr(walk, dialect, statement.where))
|
|
11975
11975
|
return false;
|
|
11976
11976
|
}
|
|
11977
|
-
addReturning(
|
|
11978
|
-
|
|
11977
|
+
addReturning(walk, statement.returning);
|
|
11978
|
+
walk.key += "}";
|
|
11979
11979
|
return true;
|
|
11980
11980
|
}
|
|
11981
|
-
function walkStatement(
|
|
11981
|
+
function walkStatement(walk, dialect, statement) {
|
|
11982
11982
|
switch (statement.kind) {
|
|
11983
11983
|
case "select":
|
|
11984
|
-
return walkSelect(
|
|
11984
|
+
return walkSelect(walk, dialect, statement);
|
|
11985
11985
|
case "insert":
|
|
11986
|
-
return walkInsert(
|
|
11986
|
+
return walkInsert(walk, dialect, statement);
|
|
11987
11987
|
case "update":
|
|
11988
|
-
return walkUpdate(
|
|
11988
|
+
return walkUpdate(walk, dialect, statement);
|
|
11989
11989
|
case "delete":
|
|
11990
|
-
return walkDelete(
|
|
11990
|
+
return walkDelete(walk, dialect, statement);
|
|
11991
11991
|
case "rlsEnable":
|
|
11992
11992
|
case "rlsForce":
|
|
11993
11993
|
case "rlsDisable":
|
|
@@ -12025,18 +12025,18 @@ function sameValues(walked, rendered) {
|
|
|
12025
12025
|
}
|
|
12026
12026
|
function renderStatementCached(params) {
|
|
12027
12027
|
const { dialect, statement, cache } = params;
|
|
12028
|
-
const
|
|
12029
|
-
if (!walkStatement(
|
|
12028
|
+
const walk = { key: "", values: [] };
|
|
12029
|
+
if (!walkStatement(walk, dialect, statement)) {
|
|
12030
12030
|
return renderStatement4({ dialect, statement });
|
|
12031
12031
|
}
|
|
12032
|
-
const slot = cache.get(
|
|
12032
|
+
const slot = cache.get(walk.key);
|
|
12033
12033
|
if (slot !== undefined) {
|
|
12034
12034
|
if (slot === null)
|
|
12035
12035
|
return renderStatement4({ dialect, statement });
|
|
12036
|
-
return { text: slot.text, values:
|
|
12036
|
+
return { text: slot.text, values: walk.values, returning: slot.returning };
|
|
12037
12037
|
}
|
|
12038
12038
|
const rendered = renderStatement4({ dialect, statement });
|
|
12039
|
-
cache.set(
|
|
12039
|
+
cache.set(walk.key, sameValues(walk.values, rendered.values) ? { text: rendered.text, returning: rendered.returning } : null);
|
|
12040
12040
|
return rendered;
|
|
12041
12041
|
}
|
|
12042
12042
|
|
|
@@ -13093,11 +13093,11 @@ async function runRows(params) {
|
|
|
13093
13093
|
return materializeRows({ dialect: engine.dialect.name, model: plan.model, rows, wire: engine.adapter.wire });
|
|
13094
13094
|
}
|
|
13095
13095
|
async function runBoundAffected(params) {
|
|
13096
|
-
const { adapter, text
|
|
13097
|
-
const
|
|
13098
|
-
if (
|
|
13099
|
-
return await
|
|
13100
|
-
return await adapter.executeUnsafe({ text
|
|
13096
|
+
const { adapter, text, values } = params;
|
|
13097
|
+
const bound = adapter.executeAffected;
|
|
13098
|
+
if (bound !== undefined)
|
|
13099
|
+
return await bound.call(adapter, { text, values });
|
|
13100
|
+
return await adapter.executeUnsafe({ text, values });
|
|
13101
13101
|
}
|
|
13102
13102
|
async function runAffected(params) {
|
|
13103
13103
|
const { engine, plan } = params;
|
|
@@ -13314,22 +13314,22 @@ async function runSingleMutation(params) {
|
|
|
13314
13314
|
if (!hasIdTrick)
|
|
13315
13315
|
throw notFound2({ model: source.model.name, method: source.method });
|
|
13316
13316
|
const where = await insertedKeyWhere({ engine: txEngine, source: { ...source, refetchWhere: null } });
|
|
13317
|
-
const
|
|
13318
|
-
if (
|
|
13317
|
+
const after = await refetch({ engine: txEngine, source, where });
|
|
13318
|
+
if (after === null)
|
|
13319
13319
|
throw notFound2({ model: source.model.name, method: source.method });
|
|
13320
|
-
return
|
|
13320
|
+
return after;
|
|
13321
13321
|
});
|
|
13322
13322
|
}
|
|
13323
13323
|
if (source.method === "update") {
|
|
13324
13324
|
return await engine.adapter.transaction(async (txAdapter) => {
|
|
13325
13325
|
const txEngine = { ...engine, adapter: txAdapter, inTransaction: true };
|
|
13326
|
-
const { affectedRows:
|
|
13327
|
-
if (
|
|
13326
|
+
const { affectedRows: affected } = await executeWrite(txEngine);
|
|
13327
|
+
if (affected === 0)
|
|
13328
13328
|
throw notFound2({ model: source.model.name, method: source.method });
|
|
13329
|
-
const
|
|
13330
|
-
if (
|
|
13329
|
+
const after = await refetch({ engine: txEngine, source, where: knownWhere });
|
|
13330
|
+
if (after === null)
|
|
13331
13331
|
throw notFound2({ model: source.model.name, method: source.method });
|
|
13332
|
-
return
|
|
13332
|
+
return after;
|
|
13333
13333
|
});
|
|
13334
13334
|
}
|
|
13335
13335
|
const { affectedRows: affected } = await executeWrite(engine);
|
|
@@ -13509,21 +13509,21 @@ function makeWriteContext(params) {
|
|
|
13509
13509
|
}
|
|
13510
13510
|
function readOnlyDelegate2(params) {
|
|
13511
13511
|
const { delegate, model } = params;
|
|
13512
|
-
const
|
|
13512
|
+
const refuse = (method) => async () => {
|
|
13513
13513
|
throw viewIsReadOnly({ model, method });
|
|
13514
13514
|
};
|
|
13515
13515
|
return {
|
|
13516
13516
|
...delegate,
|
|
13517
|
-
create:
|
|
13518
|
-
createMany:
|
|
13519
|
-
createManyAndReturn:
|
|
13520
|
-
update:
|
|
13521
|
-
updateMany:
|
|
13522
|
-
updateManyAndReturn:
|
|
13523
|
-
upsert:
|
|
13524
|
-
upsertMany:
|
|
13525
|
-
delete:
|
|
13526
|
-
deleteMany:
|
|
13517
|
+
create: refuse("create"),
|
|
13518
|
+
createMany: refuse("createMany"),
|
|
13519
|
+
createManyAndReturn: refuse("createManyAndReturn"),
|
|
13520
|
+
update: refuse("update"),
|
|
13521
|
+
updateMany: refuse("updateMany"),
|
|
13522
|
+
updateManyAndReturn: refuse("updateManyAndReturn"),
|
|
13523
|
+
upsert: refuse("upsert"),
|
|
13524
|
+
upsertMany: refuse("upsertMany"),
|
|
13525
|
+
delete: refuse("delete"),
|
|
13526
|
+
deleteMany: refuse("deleteMany")
|
|
13527
13527
|
};
|
|
13528
13528
|
}
|
|
13529
13529
|
function isEffectivelyEmptyData(value) {
|
|
@@ -13574,7 +13574,7 @@ function createDelegate(params) {
|
|
|
13574
13574
|
});
|
|
13575
13575
|
}
|
|
13576
13576
|
const shape = resolveResultShape({ meta: target.meta, model: modelMeta, method: "create", args });
|
|
13577
|
-
const
|
|
13577
|
+
const row = await createWithNested({
|
|
13578
13578
|
ctx: makeWriteContext({ engine: target }),
|
|
13579
13579
|
model: modelMeta,
|
|
13580
13580
|
data: args.data
|
|
@@ -13583,7 +13583,7 @@ function createDelegate(params) {
|
|
|
13583
13583
|
engine: target,
|
|
13584
13584
|
model: modelMeta,
|
|
13585
13585
|
shape: { ...shape, relationStrategy: "query" },
|
|
13586
|
-
row
|
|
13586
|
+
row
|
|
13587
13587
|
});
|
|
13588
13588
|
}
|
|
13589
13589
|
const built = plan({ engine: target, model, method: "create", args });
|
|
@@ -13601,7 +13601,7 @@ function createDelegate(params) {
|
|
|
13601
13601
|
const modelMeta = getModelMeta({ meta: target.meta, model });
|
|
13602
13602
|
if (hasNestedWrites({ model: modelMeta, data: args.data })) {
|
|
13603
13603
|
const shape = resolveResultShape({ meta: target.meta, model: modelMeta, method: "update", args });
|
|
13604
|
-
const
|
|
13604
|
+
const row = await updateWithNested({
|
|
13605
13605
|
ctx: makeWriteContext({ engine: target }),
|
|
13606
13606
|
model: modelMeta,
|
|
13607
13607
|
where: args.where,
|
|
@@ -13611,7 +13611,7 @@ function createDelegate(params) {
|
|
|
13611
13611
|
engine: target,
|
|
13612
13612
|
model: modelMeta,
|
|
13613
13613
|
shape: { ...shape, relationStrategy: "query" },
|
|
13614
|
-
row
|
|
13614
|
+
row
|
|
13615
13615
|
});
|
|
13616
13616
|
}
|
|
13617
13617
|
const built = plan({ engine: target, model, method: "update", args });
|
|
@@ -13688,12 +13688,12 @@ function createDelegate(params) {
|
|
|
13688
13688
|
method: "upsert",
|
|
13689
13689
|
args
|
|
13690
13690
|
});
|
|
13691
|
-
const
|
|
13691
|
+
const row = await runUpsertFallback({ engine: target, model: modelMeta, args });
|
|
13692
13692
|
return await finalizeRow({
|
|
13693
13693
|
engine: target,
|
|
13694
13694
|
model: modelMeta,
|
|
13695
13695
|
shape: { ...shape, relationStrategy: "query" },
|
|
13696
|
-
row
|
|
13696
|
+
row
|
|
13697
13697
|
});
|
|
13698
13698
|
}
|
|
13699
13699
|
const built = plan({ engine: target, model, method: "upsert", args });
|
|
@@ -13848,11 +13848,11 @@ function withStrictArguments(params) {
|
|
|
13848
13848
|
function buildRawStatement(params) {
|
|
13849
13849
|
const { dialect, strings, values } = params;
|
|
13850
13850
|
const collector = new ParamCollector(dialect);
|
|
13851
|
-
let
|
|
13851
|
+
let text = strings[0] ?? "";
|
|
13852
13852
|
for (let index = 0;index < values.length; index++) {
|
|
13853
|
-
|
|
13853
|
+
text += collector.add(values[index]) + (strings[index + 1] ?? "");
|
|
13854
13854
|
}
|
|
13855
|
-
return { text
|
|
13855
|
+
return { text, values: collector.values };
|
|
13856
13856
|
}
|
|
13857
13857
|
function buildClient(params) {
|
|
13858
13858
|
const { engine } = params;
|
|
@@ -13869,7 +13869,7 @@ function buildClient(params) {
|
|
|
13869
13869
|
models[model.name] = delegate;
|
|
13870
13870
|
models[model.clientName] = delegate;
|
|
13871
13871
|
}
|
|
13872
|
-
const runRaw = async (method, statement,
|
|
13872
|
+
const runRaw = async (method, statement, decodeRows) => {
|
|
13873
13873
|
const scope = beginOperation({ engine, kind: "raw", model: null, method });
|
|
13874
13874
|
scope?.dispatch();
|
|
13875
13875
|
const running = executeOperation({
|
|
@@ -13885,7 +13885,7 @@ function buildClient(params) {
|
|
|
13885
13885
|
rowCount: (value) => method.startsWith("$query") ? value.rows.length : value.affectedRows,
|
|
13886
13886
|
run: () => statement.values.length > 0 ? target.adapter.executeRawBound !== undefined ? target.adapter.executeRawBound(statement) : runBoundAffected({ adapter: target.adapter, text: statement.text, values: statement.values }) : target.adapter.executeUnsafe(statement)
|
|
13887
13887
|
});
|
|
13888
|
-
|
|
13888
|
+
decodeRows?.(result.rows);
|
|
13889
13889
|
return result;
|
|
13890
13890
|
}
|
|
13891
13891
|
});
|
|
@@ -13901,8 +13901,8 @@ function buildClient(params) {
|
|
|
13901
13901
|
});
|
|
13902
13902
|
return await running;
|
|
13903
13903
|
};
|
|
13904
|
-
const runAdvisoryLock = async (
|
|
13905
|
-
const { method, options } =
|
|
13904
|
+
const runAdvisoryLock = async (params) => {
|
|
13905
|
+
const { method, options } = params;
|
|
13906
13906
|
assertEngineActive({ engine });
|
|
13907
13907
|
const statement = compileAdvisoryLock({
|
|
13908
13908
|
dialect: engine.dialect,
|
|
@@ -14048,8 +14048,8 @@ function buildClient(params) {
|
|
|
14048
14048
|
},
|
|
14049
14049
|
$queryRaw: async (strings, ...values) => (await runRaw("$queryRaw", buildRawStatement({ dialect: engine.dialect, strings, values }))).rows,
|
|
14050
14050
|
$executeRaw: async (strings, ...values) => (await runRaw("$executeRaw", buildRawStatement({ dialect: engine.dialect, strings, values }))).affectedRows,
|
|
14051
|
-
$queryRawUnsafe: async (
|
|
14052
|
-
$executeRawUnsafe: async (
|
|
14051
|
+
$queryRawUnsafe: async (text, ...values) => (await runRaw("$queryRawUnsafe", { text, values })).rows,
|
|
14052
|
+
$executeRawUnsafe: async (text, ...values) => (await runRaw("$executeRawUnsafe", { text, values })).affectedRows,
|
|
14053
14053
|
$advisoryLock: async (options) => {
|
|
14054
14054
|
await runAdvisoryLock({ method: "$advisoryLock", options });
|
|
14055
14055
|
},
|
|
@@ -14095,7 +14095,7 @@ function buildClient(params) {
|
|
|
14095
14095
|
}
|
|
14096
14096
|
attachExtensionMounts({ engine, client, models });
|
|
14097
14097
|
attachDefineView({ client, meta: engine.meta, models });
|
|
14098
|
-
const wrapDelegate = engine.options?.strictArguments !== false ? (
|
|
14098
|
+
const wrapDelegate = engine.options?.strictArguments !== false ? (params) => withStrictArguments({ engine, ...params }) : undefined;
|
|
14099
14099
|
if (engine.rlsSchema === undefined)
|
|
14100
14100
|
attachScoped({ client, meta: engine.meta, ...wrapDelegate === undefined ? {} : { wrapDelegate } });
|
|
14101
14101
|
if (engine.rlsSchema === undefined) {
|
|
@@ -14170,7 +14170,7 @@ function makeMountContext(params) {
|
|
|
14170
14170
|
provider: engine.adapter.provider,
|
|
14171
14171
|
meta: engine.meta,
|
|
14172
14172
|
model,
|
|
14173
|
-
executeRows: async ({ text
|
|
14173
|
+
executeRows: async ({ text, values, method }) => {
|
|
14174
14174
|
const scope = beginOperation({
|
|
14175
14175
|
engine,
|
|
14176
14176
|
kind: "extension",
|
|
@@ -14186,11 +14186,11 @@ function makeMountContext(params) {
|
|
|
14186
14186
|
kind: "extension",
|
|
14187
14187
|
model: model?.name ?? null,
|
|
14188
14188
|
method: method ?? extension,
|
|
14189
|
-
text
|
|
14189
|
+
text,
|
|
14190
14190
|
values,
|
|
14191
14191
|
rowCount: (value) => value.length,
|
|
14192
14192
|
run: () => target.adapter.execute({
|
|
14193
|
-
text
|
|
14193
|
+
text,
|
|
14194
14194
|
values: bindValues({ adapter: target.adapter, values: [...values] })
|
|
14195
14195
|
})
|
|
14196
14196
|
});
|
|
@@ -14273,8 +14273,8 @@ function attachExtensionMounts(params) {
|
|
|
14273
14273
|
meta: { extension: mount.extension, model: model.name, property: mount.property }
|
|
14274
14274
|
});
|
|
14275
14275
|
}
|
|
14276
|
-
const
|
|
14277
|
-
Object.defineProperty(delegate, mount.property, { value
|
|
14276
|
+
const value = createMountSurface({ engine, mount, model });
|
|
14277
|
+
Object.defineProperty(delegate, mount.property, { value, enumerable: true, configurable: true });
|
|
14278
14278
|
continue;
|
|
14279
14279
|
}
|
|
14280
14280
|
if (!mount.property.startsWith("$") || mount.property in client) {
|
|
@@ -14414,8 +14414,8 @@ function validation(params) {
|
|
|
14414
14414
|
return new VibeError32({ code: "VIBE_VALIDATION", message: params.message, meta: params.meta });
|
|
14415
14415
|
}
|
|
14416
14416
|
function projectionFor(params) {
|
|
14417
|
-
const { plan
|
|
14418
|
-
const names =
|
|
14417
|
+
const { plan, select, omit } = params;
|
|
14418
|
+
const names = plan.keys.map((key) => key.field.name);
|
|
14419
14419
|
if (select !== undefined) {
|
|
14420
14420
|
const hidden = names.filter((name) => select[name] !== true);
|
|
14421
14421
|
if (hidden.length === 0)
|
|
@@ -14445,13 +14445,13 @@ function iterateKeyset(options) {
|
|
|
14445
14445
|
});
|
|
14446
14446
|
}
|
|
14447
14447
|
const model = getModelMeta({ meta, model: options.model });
|
|
14448
|
-
const
|
|
14448
|
+
const plan = compileKeysetOrderPlan({
|
|
14449
14449
|
model,
|
|
14450
14450
|
dialect,
|
|
14451
14451
|
terms: compileKeysetOrderInputs({ dialect, meta, model, orderBy }),
|
|
14452
14452
|
...options.timestampPrecision === undefined ? {} : { timestampPrecision: options.timestampPrecision }
|
|
14453
14453
|
});
|
|
14454
|
-
const projection = projectionFor({ plan
|
|
14454
|
+
const projection = projectionFor({ plan, select: options.select, omit: options.omit });
|
|
14455
14455
|
const keysetArg = options.timestampPrecision === undefined ? {} : { keyset: { timestampPrecision: options.timestampPrecision } };
|
|
14456
14456
|
let buffer = [];
|
|
14457
14457
|
let position = options.after ?? null;
|
|
@@ -14482,16 +14482,16 @@ function iterateKeyset(options) {
|
|
|
14482
14482
|
const first = rows[0];
|
|
14483
14483
|
if (position !== null && first !== undefined) {
|
|
14484
14484
|
const advanced = keysetRowIsAfter({
|
|
14485
|
-
keys:
|
|
14486
|
-
row: keysetRowValues({ plan
|
|
14487
|
-
position: decodeKeysetToken({ plan
|
|
14485
|
+
keys: plan.keys,
|
|
14486
|
+
row: keysetRowValues({ plan, row: first }),
|
|
14487
|
+
position: decodeKeysetToken({ plan, token: position })
|
|
14488
14488
|
});
|
|
14489
14489
|
if (advanced === false) {
|
|
14490
14490
|
stop();
|
|
14491
14491
|
throw new VibeError32({
|
|
14492
14492
|
code: "VIBE_DATA_INVALID",
|
|
14493
14493
|
message: `keyset traversal of "${options.model}" is not advancing: the engine returned a row that does not sort after the previous position. ` + "The ordering is not total, or a cursor value lost precision \u2014 a DateTime column finer than milliseconds asserted as millisecond-exact does this.",
|
|
14494
|
-
meta: { model: options.model, order:
|
|
14494
|
+
meta: { model: options.model, order: plan.signature, reason: "keyset-position-not-advancing" }
|
|
14495
14495
|
});
|
|
14496
14496
|
}
|
|
14497
14497
|
}
|
|
@@ -14523,7 +14523,7 @@ function iterateKeyset(options) {
|
|
|
14523
14523
|
}
|
|
14524
14524
|
}
|
|
14525
14525
|
const raw = buffer.shift();
|
|
14526
|
-
pending = encodeKeysetToken({ plan
|
|
14526
|
+
pending = encodeKeysetToken({ plan, row: raw });
|
|
14527
14527
|
position = pending;
|
|
14528
14528
|
if (projection.hidden.length === 0)
|
|
14529
14529
|
return { done: false, value: raw };
|
|
@@ -14643,115 +14643,115 @@ function createTelemetryCollector(params) {
|
|
|
14643
14643
|
};
|
|
14644
14644
|
}
|
|
14645
14645
|
export {
|
|
14646
|
-
|
|
14647
|
-
updateWithNested,
|
|
14648
|
-
toSqlExecutor,
|
|
14649
|
-
toClientName,
|
|
14650
|
-
summarizePlan,
|
|
14651
|
-
sqlProjection,
|
|
14652
|
-
sql2 as sql,
|
|
14653
|
-
rewriteScopedCall,
|
|
14654
|
-
resolveTelemetryConfig,
|
|
14655
|
-
resolveStatementDiagnostics,
|
|
14656
|
-
resolveScopedModels,
|
|
14657
|
-
resolveResultShape,
|
|
14658
|
-
resolveRelationSelection,
|
|
14659
|
-
resolveRelationLink,
|
|
14660
|
-
recommendFromPlan,
|
|
14661
|
-
readWorkloadStatistics,
|
|
14662
|
-
readOnlyRefusal,
|
|
14663
|
-
queryFingerprint,
|
|
14664
|
-
previewOperation,
|
|
14665
|
-
parsePostgresPlan,
|
|
14666
|
-
parseDiagnosticsEnv,
|
|
14667
|
-
parameterTypeTag,
|
|
14668
|
-
normalizeSql,
|
|
14669
|
-
lateralColumnAlias,
|
|
14670
|
-
keysetRowValues,
|
|
14671
|
-
keysetRowIsAfter,
|
|
14672
|
-
iterateKeyset,
|
|
14673
|
-
isExecutableRead,
|
|
14674
|
-
isDbNow,
|
|
14675
|
-
inspectNativeRlsTransaction,
|
|
14676
|
-
inspectNativeRls,
|
|
14677
|
-
inheritReadOnly,
|
|
14678
|
-
hasNestedWrites,
|
|
14679
|
-
getModelMeta,
|
|
14680
|
-
getFieldMeta,
|
|
14681
|
-
getCodec,
|
|
14682
|
-
generateUuid,
|
|
14683
|
-
generateUlid,
|
|
14684
|
-
generateNanoid,
|
|
14685
|
-
generateDefaultValue,
|
|
14686
|
-
generateCuid,
|
|
14687
|
-
formatStatementDiagnostic,
|
|
14688
|
-
formatNativeRlsReport,
|
|
14689
|
-
explainSql,
|
|
14690
|
-
explainOperation,
|
|
14691
|
-
explainOnSession,
|
|
14692
|
-
encodeValue,
|
|
14693
|
-
encodeKeysetToken,
|
|
14694
|
-
delegateMethodAccess,
|
|
14695
|
-
defineDatabaseModule,
|
|
14696
|
-
decodeValue,
|
|
14697
|
-
decodeRows,
|
|
14698
|
-
decodeRow,
|
|
14699
|
-
decodeKeysetToken,
|
|
14700
|
-
decodeIsNoop2 as decodeIsNoop,
|
|
14701
|
-
decodeAggregateValue,
|
|
14702
|
-
decode2 as decode,
|
|
14703
|
-
dbNow,
|
|
14704
|
-
createWithNested,
|
|
14705
|
-
createView,
|
|
14706
|
-
createTelemetryRecorder,
|
|
14707
|
-
createTelemetryCollector,
|
|
14708
|
-
createStatementDiagnostics,
|
|
14709
|
-
createSqlModel,
|
|
14710
|
-
createScopeRewriter,
|
|
14711
|
-
createClient,
|
|
14712
|
-
compileWhere,
|
|
14713
|
-
compileSelect,
|
|
14714
|
-
compileOrderBy,
|
|
14715
|
-
compileKeysetOrderPlan,
|
|
14716
|
-
compileKeysetOrderInputs,
|
|
14717
|
-
compileAdvisoryLock,
|
|
14718
|
-
clientMemberAccess,
|
|
14719
|
-
checkStrictArguments,
|
|
14720
|
-
buildRuntimeMeta,
|
|
14721
|
-
buildQuery,
|
|
14722
|
-
buildExtensionOperatorMap,
|
|
14723
|
-
buildConnectHooks,
|
|
14724
|
-
attachScoped,
|
|
14725
|
-
attachRelations,
|
|
14726
|
-
attachReadOnly,
|
|
14727
|
-
attachPolicy,
|
|
14728
|
-
attachLateralRelations,
|
|
14729
|
-
attachDefineView,
|
|
14730
|
-
assertNativeRlsReady,
|
|
14731
|
-
assertExtensionManifest,
|
|
14732
|
-
assertComputedManifest,
|
|
14733
|
-
applyWriteValidators,
|
|
14734
|
-
applyComputedFields,
|
|
14735
|
-
analyzeOperationTelemetry,
|
|
14736
|
-
affectedRowsAreRowCounts,
|
|
14737
|
-
WRITE_DELEGATE_METHODS,
|
|
14738
|
-
ViewResult,
|
|
14739
|
-
TELEMETRY_DEFAULTS,
|
|
14740
|
-
STATEMENT_DIAGNOSTICS_DEFAULTS,
|
|
14741
|
-
SQLITE_CODECS,
|
|
14742
|
-
SKIP,
|
|
14743
|
-
READ_DELEGATE_METHODS,
|
|
14744
|
-
POSTGRES_CODECS,
|
|
14745
|
-
PLAN_DEFAULTS,
|
|
14746
|
-
MYSQL_CODECS,
|
|
14747
|
-
KEYSET_TOKEN_VERSION,
|
|
14748
|
-
KEYSET_TOKEN_PREFIX,
|
|
14749
|
-
KEYSET_MAX_PAGE_SIZE,
|
|
14750
|
-
DIALECT_CODECS2 as DIALECT_CODECS,
|
|
14751
|
-
DIAGNOSTIC_THRESHOLDS,
|
|
14752
|
-
DELEGATE_METHOD_ACCESS,
|
|
14646
|
+
CLIENT_MEMBER_ACCESS,
|
|
14753
14647
|
COUNT_ALIAS,
|
|
14754
|
-
|
|
14648
|
+
DELEGATE_METHOD_ACCESS,
|
|
14649
|
+
DIAGNOSTIC_THRESHOLDS,
|
|
14650
|
+
DIALECT_CODECS2 as DIALECT_CODECS,
|
|
14651
|
+
KEYSET_MAX_PAGE_SIZE,
|
|
14652
|
+
KEYSET_TOKEN_PREFIX,
|
|
14653
|
+
KEYSET_TOKEN_VERSION,
|
|
14654
|
+
MYSQL_CODECS,
|
|
14655
|
+
PLAN_DEFAULTS,
|
|
14656
|
+
POSTGRES_CODECS,
|
|
14657
|
+
READ_DELEGATE_METHODS,
|
|
14658
|
+
SKIP,
|
|
14659
|
+
SQLITE_CODECS,
|
|
14660
|
+
STATEMENT_DIAGNOSTICS_DEFAULTS,
|
|
14661
|
+
TELEMETRY_DEFAULTS,
|
|
14662
|
+
ViewResult,
|
|
14663
|
+
WRITE_DELEGATE_METHODS,
|
|
14664
|
+
affectedRowsAreRowCounts,
|
|
14665
|
+
analyzeOperationTelemetry,
|
|
14666
|
+
applyComputedFields,
|
|
14667
|
+
applyWriteValidators,
|
|
14668
|
+
assertComputedManifest,
|
|
14669
|
+
assertExtensionManifest,
|
|
14670
|
+
assertNativeRlsReady,
|
|
14671
|
+
attachDefineView,
|
|
14672
|
+
attachLateralRelations,
|
|
14673
|
+
attachPolicy,
|
|
14674
|
+
attachReadOnly,
|
|
14675
|
+
attachRelations,
|
|
14676
|
+
attachScoped,
|
|
14677
|
+
buildConnectHooks,
|
|
14678
|
+
buildExtensionOperatorMap,
|
|
14679
|
+
buildQuery,
|
|
14680
|
+
buildRuntimeMeta,
|
|
14681
|
+
checkStrictArguments,
|
|
14682
|
+
clientMemberAccess,
|
|
14683
|
+
compileAdvisoryLock,
|
|
14684
|
+
compileKeysetOrderInputs,
|
|
14685
|
+
compileKeysetOrderPlan,
|
|
14686
|
+
compileOrderBy,
|
|
14687
|
+
compileSelect,
|
|
14688
|
+
compileWhere,
|
|
14689
|
+
createClient,
|
|
14690
|
+
createScopeRewriter,
|
|
14691
|
+
createSqlModel,
|
|
14692
|
+
createStatementDiagnostics,
|
|
14693
|
+
createTelemetryCollector,
|
|
14694
|
+
createTelemetryRecorder,
|
|
14695
|
+
createView,
|
|
14696
|
+
createWithNested,
|
|
14697
|
+
dbNow,
|
|
14698
|
+
decode2 as decode,
|
|
14699
|
+
decodeAggregateValue,
|
|
14700
|
+
decodeIsNoop2 as decodeIsNoop,
|
|
14701
|
+
decodeKeysetToken,
|
|
14702
|
+
decodeRow,
|
|
14703
|
+
decodeRows,
|
|
14704
|
+
decodeValue,
|
|
14705
|
+
defineDatabaseModule,
|
|
14706
|
+
delegateMethodAccess,
|
|
14707
|
+
encodeKeysetToken,
|
|
14708
|
+
encodeValue,
|
|
14709
|
+
explainOnSession,
|
|
14710
|
+
explainOperation,
|
|
14711
|
+
explainSql,
|
|
14712
|
+
formatNativeRlsReport,
|
|
14713
|
+
formatStatementDiagnostic,
|
|
14714
|
+
generateCuid,
|
|
14715
|
+
generateDefaultValue,
|
|
14716
|
+
generateNanoid,
|
|
14717
|
+
generateUlid,
|
|
14718
|
+
generateUuid,
|
|
14719
|
+
getCodec,
|
|
14720
|
+
getFieldMeta,
|
|
14721
|
+
getModelMeta,
|
|
14722
|
+
hasNestedWrites,
|
|
14723
|
+
inheritReadOnly,
|
|
14724
|
+
inspectNativeRls,
|
|
14725
|
+
inspectNativeRlsTransaction,
|
|
14726
|
+
isDbNow,
|
|
14727
|
+
isExecutableRead,
|
|
14728
|
+
iterateKeyset,
|
|
14729
|
+
keysetRowIsAfter,
|
|
14730
|
+
keysetRowValues,
|
|
14731
|
+
lateralColumnAlias,
|
|
14732
|
+
normalizeSql,
|
|
14733
|
+
parameterTypeTag,
|
|
14734
|
+
parseDiagnosticsEnv,
|
|
14735
|
+
parsePostgresPlan,
|
|
14736
|
+
previewOperation,
|
|
14737
|
+
queryFingerprint,
|
|
14738
|
+
readOnlyRefusal,
|
|
14739
|
+
readWorkloadStatistics,
|
|
14740
|
+
recommendFromPlan,
|
|
14741
|
+
resolveRelationLink,
|
|
14742
|
+
resolveRelationSelection,
|
|
14743
|
+
resolveResultShape,
|
|
14744
|
+
resolveScopedModels,
|
|
14745
|
+
resolveStatementDiagnostics,
|
|
14746
|
+
resolveTelemetryConfig,
|
|
14747
|
+
rewriteScopedCall,
|
|
14748
|
+
sql2 as sql,
|
|
14749
|
+
sqlProjection,
|
|
14750
|
+
summarizePlan,
|
|
14751
|
+
toClientName,
|
|
14752
|
+
toSqlExecutor,
|
|
14753
|
+
updateWithNested,
|
|
14754
|
+
validateWriteData
|
|
14755
14755
|
};
|
|
14756
14756
|
|
|
14757
|
-
//# debugId=
|
|
14757
|
+
//# debugId=28EC8E14B301CBEB64756E2164756E21
|