prisma-sql 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generator.cjs +57 -14
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +57 -14
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +5 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -6,13 +6,14 @@ declare function setGlobalDialect(dialect: SqlDialect): void;
|
|
|
6
6
|
declare function getGlobalDialect(): SqlDialect;
|
|
7
7
|
|
|
8
8
|
interface SQLDirective {
|
|
9
|
-
|
|
9
|
+
method: PrismaMethod$1;
|
|
10
10
|
sql: string;
|
|
11
11
|
staticParams: any[];
|
|
12
12
|
dynamicKeys: string[];
|
|
13
13
|
paramMappings: readonly ParamMap[];
|
|
14
14
|
originalDirective: DirectiveProps;
|
|
15
15
|
}
|
|
16
|
+
type PrismaMethod$1 = 'findMany' | 'findFirst' | 'findUnique' | 'aggregate' | 'groupBy' | 'count';
|
|
16
17
|
|
|
17
18
|
type PrismaMethod = 'findMany' | 'findFirst' | 'findUnique' | 'count' | 'aggregate' | 'groupBy';
|
|
18
19
|
declare function transformQueryResults(method: PrismaMethod, results: unknown[]): unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,13 +6,14 @@ declare function setGlobalDialect(dialect: SqlDialect): void;
|
|
|
6
6
|
declare function getGlobalDialect(): SqlDialect;
|
|
7
7
|
|
|
8
8
|
interface SQLDirective {
|
|
9
|
-
|
|
9
|
+
method: PrismaMethod$1;
|
|
10
10
|
sql: string;
|
|
11
11
|
staticParams: any[];
|
|
12
12
|
dynamicKeys: string[];
|
|
13
13
|
paramMappings: readonly ParamMap[];
|
|
14
14
|
originalDirective: DirectiveProps;
|
|
15
15
|
}
|
|
16
|
+
type PrismaMethod$1 = 'findMany' | 'findFirst' | 'findUnique' | 'aggregate' | 'groupBy' | 'count';
|
|
16
17
|
|
|
17
18
|
type PrismaMethod = 'findMany' | 'findFirst' | 'findUnique' | 'count' | 'aggregate' | 'groupBy';
|
|
18
19
|
declare function transformQueryResults(method: PrismaMethod, results: unknown[]): unknown;
|
package/dist/index.js
CHANGED
|
@@ -4072,14 +4072,6 @@ function safeAlias(input) {
|
|
|
4072
4072
|
}
|
|
4073
4073
|
return base;
|
|
4074
4074
|
}
|
|
4075
|
-
function isPrismaMethod(v) {
|
|
4076
|
-
return v === "findMany" || v === "findFirst" || v === "findUnique" || v === "aggregate" || v === "groupBy" || v === "count";
|
|
4077
|
-
}
|
|
4078
|
-
function getMethodFromProcessed(processed) {
|
|
4079
|
-
const maybe = processed == null ? void 0 : processed.method;
|
|
4080
|
-
if (isPrismaMethod(maybe)) return maybe;
|
|
4081
|
-
return "findMany";
|
|
4082
|
-
}
|
|
4083
4075
|
function buildSqlResult(args) {
|
|
4084
4076
|
const {
|
|
4085
4077
|
method,
|
|
@@ -4192,6 +4184,7 @@ function buildMainWhere(args) {
|
|
|
4192
4184
|
}
|
|
4193
4185
|
function buildAndNormalizeSql(args) {
|
|
4194
4186
|
const {
|
|
4187
|
+
method,
|
|
4195
4188
|
processed,
|
|
4196
4189
|
whereResult,
|
|
4197
4190
|
tableName,
|
|
@@ -4200,7 +4193,6 @@ function buildAndNormalizeSql(args) {
|
|
|
4200
4193
|
schemaModels,
|
|
4201
4194
|
dialect
|
|
4202
4195
|
} = args;
|
|
4203
|
-
const method = getMethodFromProcessed(processed);
|
|
4204
4196
|
const sqlResult = buildSqlResult({
|
|
4205
4197
|
method,
|
|
4206
4198
|
processed,
|
|
@@ -4222,7 +4214,7 @@ function finalizeDirective(args) {
|
|
|
4222
4214
|
validateSqlPositions(normalizedSql, normalizedMappings, getGlobalDialect());
|
|
4223
4215
|
const { staticParams, dynamicKeys } = buildParamsFromMappings(normalizedMappings);
|
|
4224
4216
|
return {
|
|
4225
|
-
|
|
4217
|
+
method: directive.method,
|
|
4226
4218
|
sql: normalizedSql,
|
|
4227
4219
|
staticParams,
|
|
4228
4220
|
dynamicKeys,
|
|
@@ -4242,7 +4234,9 @@ function generateSQL(directive) {
|
|
|
4242
4234
|
modelDef,
|
|
4243
4235
|
dialect
|
|
4244
4236
|
});
|
|
4237
|
+
const method = directive.method;
|
|
4245
4238
|
const normalized = buildAndNormalizeSql({
|
|
4239
|
+
method,
|
|
4246
4240
|
processed: query.processed,
|
|
4247
4241
|
whereResult,
|
|
4248
4242
|
tableName,
|
|
@@ -4604,7 +4598,7 @@ function generateAllSQL(directives) {
|
|
|
4604
4598
|
);
|
|
4605
4599
|
for (const { directive, error } of errors) {
|
|
4606
4600
|
console.warn(
|
|
4607
|
-
` - ${directive.modelName}.${directive.
|
|
4601
|
+
` - ${directive.modelName}.${directive.method}: ${error.message}`
|
|
4608
4602
|
);
|
|
4609
4603
|
}
|
|
4610
4604
|
}
|