prisma-sql 1.41.0 → 1.43.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 +20 -11
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +20 -11
- package/dist/generator.js.map +1 -1
- package/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -56,7 +56,7 @@ var require_package = __commonJS({
|
|
|
56
56
|
"package.json"(exports$1, module) {
|
|
57
57
|
module.exports = {
|
|
58
58
|
name: "prisma-sql",
|
|
59
|
-
version: "1.
|
|
59
|
+
version: "1.43.0",
|
|
60
60
|
description: "Convert Prisma queries to optimized SQL with type safety. 2-7x faster than Prisma Client.",
|
|
61
61
|
main: "dist/index.cjs",
|
|
62
62
|
module: "dist/index.js",
|
|
@@ -3812,7 +3812,12 @@ function buildSelectSpec(input) {
|
|
|
3812
3812
|
model,
|
|
3813
3813
|
alias
|
|
3814
3814
|
);
|
|
3815
|
-
const orderByClause = buildOrderByClause(
|
|
3815
|
+
const orderByClause = buildOrderByClause(
|
|
3816
|
+
normalizedArgs,
|
|
3817
|
+
alias,
|
|
3818
|
+
dialect,
|
|
3819
|
+
model
|
|
3820
|
+
);
|
|
3816
3821
|
const { take, skip, cursor } = getPaginationParams(method, normalizedArgs);
|
|
3817
3822
|
const params = createParamStoreFrom(
|
|
3818
3823
|
whereResult.params,
|
|
@@ -4672,6 +4677,18 @@ function generateCode(models, queries, dialect, datamodel) {
|
|
|
4672
4677
|
return `// Generated by @prisma-sql/generator - DO NOT EDIT
|
|
4673
4678
|
import { buildSQL, transformQueryResults, type PrismaMethod, type Model } from 'prisma-sql'
|
|
4674
4679
|
|
|
4680
|
+
function normalizeValue(value: unknown): unknown {
|
|
4681
|
+
if (value instanceof Date) {
|
|
4682
|
+
return value.toISOString()
|
|
4683
|
+
}
|
|
4684
|
+
|
|
4685
|
+
if (Array.isArray(value)) {
|
|
4686
|
+
return value.map(normalizeValue)
|
|
4687
|
+
}
|
|
4688
|
+
|
|
4689
|
+
return value
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4675
4692
|
export const MODELS: Model[] = ${JSON.stringify(cleanModels, null, 2)}
|
|
4676
4693
|
|
|
4677
4694
|
const ENUM_MAPPINGS: Record<string, Record<string, string>> = ${JSON.stringify(mappings, null, 2)}
|
|
@@ -4701,7 +4718,6 @@ function transformEnumInValue(value: unknown, enumType: string | undefined): unk
|
|
|
4701
4718
|
return value
|
|
4702
4719
|
}
|
|
4703
4720
|
|
|
4704
|
-
// Handle array of enum values
|
|
4705
4721
|
if (Array.isArray(value)) {
|
|
4706
4722
|
return value.map(v => {
|
|
4707
4723
|
if (typeof v === 'string' && mapping[v] !== undefined) {
|
|
@@ -4711,7 +4727,6 @@ function transformEnumInValue(value: unknown, enumType: string | undefined): unk
|
|
|
4711
4727
|
})
|
|
4712
4728
|
}
|
|
4713
4729
|
|
|
4714
|
-
// Handle single enum value
|
|
4715
4730
|
if (typeof value === 'string' && mapping[value] !== undefined) {
|
|
4716
4731
|
return mapping[value]
|
|
4717
4732
|
}
|
|
@@ -4735,24 +4750,19 @@ function transformEnumValues(modelName: string, obj: any, currentPath: string[]
|
|
|
4735
4750
|
for (const [key, value] of Object.entries(obj)) {
|
|
4736
4751
|
const newPath = [...currentPath, key]
|
|
4737
4752
|
|
|
4738
|
-
// Check if current key is an enum field at root level
|
|
4739
4753
|
const enumType = modelFields[key]
|
|
4740
4754
|
|
|
4741
4755
|
if (enumType) {
|
|
4742
|
-
// This is an enum field - check if value is direct or has operators
|
|
4743
4756
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
4744
|
-
// Has operators like { equals: "ACTIVE" }, { in: ["ACTIVE"] }, etc.
|
|
4745
4757
|
const transformedOperators: any = {}
|
|
4746
4758
|
for (const [op, opValue] of Object.entries(value)) {
|
|
4747
4759
|
transformedOperators[op] = transformEnumInValue(opValue, enumType)
|
|
4748
4760
|
}
|
|
4749
4761
|
transformed[key] = transformedOperators
|
|
4750
4762
|
} else {
|
|
4751
|
-
// Direct value like { status: "ACTIVE" }
|
|
4752
4763
|
transformed[key] = transformEnumInValue(value, enumType)
|
|
4753
4764
|
}
|
|
4754
4765
|
} else if (typeof value === 'object' && value !== null) {
|
|
4755
|
-
// Recursively transform nested objects (relations, logical operators, etc)
|
|
4756
4766
|
transformed[key] = transformEnumValues(modelName, value, newPath)
|
|
4757
4767
|
} else {
|
|
4758
4768
|
transformed[key] = value
|
|
@@ -4828,7 +4838,7 @@ function extractDynamicParams(args: any, dynamicKeys: string[]): unknown[] {
|
|
|
4828
4838
|
throw new Error(\`Missing required parameter: \${key}\`)
|
|
4829
4839
|
}
|
|
4830
4840
|
|
|
4831
|
-
params.push(value)
|
|
4841
|
+
params.push(normalizeValue(value))
|
|
4832
4842
|
}
|
|
4833
4843
|
|
|
4834
4844
|
return params
|
|
@@ -4879,7 +4889,6 @@ export function speedExtension(config: {
|
|
|
4879
4889
|
const modelName = this?.name || this?.$name
|
|
4880
4890
|
const startTime = Date.now()
|
|
4881
4891
|
|
|
4882
|
-
// Transform enum values before processing
|
|
4883
4892
|
const transformedArgs = transformEnumValues(modelName, args || {})
|
|
4884
4893
|
|
|
4885
4894
|
const queryKey = normalizeQuery(transformedArgs)
|