diff --git a/src/packages/client/fixtures/scalarList/.gitignore b/src/packages/client/fixtures/scalarList/.gitignore new file mode 100644 index 000000000000..f8aa4ebdb381 --- /dev/null +++ b/src/packages/client/fixtures/scalarList/.gitignore @@ -0,0 +1,3 @@ +@prisma +migrations +db \ No newline at end of file diff --git a/src/packages/client/fixtures/scalarList/main.ts b/src/packages/client/fixtures/scalarList/main.ts new file mode 100644 index 000000000000..94dbe1e09c4f --- /dev/null +++ b/src/packages/client/fixtures/scalarList/main.ts @@ -0,0 +1,23 @@ +import { PrismaClient } from './@prisma/client' + +async function main() { + const prisma = new PrismaClient() + + await prisma.user.create({ + data: { + hobbies: { + set: [ + 'sample 1 string', + '7fb1aef9-5250-4cf6-92c7-b01f53862822', + 'sample 3 string', + '575e0b28-81fa-43e0-8f05-708a98d55c14', + 'sample 5 string', + ], + }, + name: 'name', + }, + }) + prisma.disconnect() +} + +main().catch(console.error) diff --git a/src/packages/client/fixtures/scalarList/prisma/schema.prisma b/src/packages/client/fixtures/scalarList/prisma/schema.prisma new file mode 100644 index 000000000000..6d81bd582d81 --- /dev/null +++ b/src/packages/client/fixtures/scalarList/prisma/schema.prisma @@ -0,0 +1,10 @@ +datasource my_db { + provider = "postgres" + url = env("POSTGRES_URL") +} + +model User { + id String @default(cuid()) @id + name String + hobbies String[] +} diff --git a/src/packages/client/fixtures/scalarList/tsconfig.json b/src/packages/client/fixtures/scalarList/tsconfig.json new file mode 100644 index 000000000000..dd45bc25d5d7 --- /dev/null +++ b/src/packages/client/fixtures/scalarList/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "strict": true, + "target": "es2018", + "module": "commonjs", + "esModuleInterop": true, + "noImplicitAny": false, + "lib": ["esnext"] + } +} diff --git a/src/packages/client/src/__tests__/uuid.test.ts b/src/packages/client/src/__tests__/uuid.test.ts new file mode 100644 index 000000000000..0c3ace4b1edf --- /dev/null +++ b/src/packages/client/src/__tests__/uuid.test.ts @@ -0,0 +1,66 @@ +import { DMMFClass, makeDocument } from '../runtime' +import { getDMMF } from '../generation/getDMMF' + +const datamodel = `datasource my_db { + provider = "postgres" + url = env("POSTGRES_URL") +} + +model User { + id String @default(cuid()) @id + name String + hobbies String[] +} +` + +describe('at least one validation', () => { + let dmmf + beforeAll(async () => { + dmmf = new DMMFClass(await getDMMF({ datamodel })) + }) + test('string first', () => { + const select = { + data: { + hobbies: { + set: [ + 'sample 1 string', + '7fb1aef9-5250-4cf6-92c7-b01f53862822', + 'sample 3 string', + '575e0b28-81fa-43e0-8f05-708a98d55c14', + 'sample 5 string', + ], + }, + name: 'name', + }, + } + const document = makeDocument({ + dmmf, + select, + rootTypeName: 'mutation', + rootField: 'createOneUser', + }) + expect(() => document.validate(select, false)).not.toThrow() + }) + test('uuid first', () => { + const select = { + data: { + hobbies: { + set: [ + '7fb1aef9-5250-4cf6-92c7-b01f53862822', + 'sample 3 string', + '575e0b28-81fa-43e0-8f05-708a98d55c14', + 'sample 5 string', + ], + }, + name: 'name', + }, + } + const document = makeDocument({ + dmmf, + select, + rootTypeName: 'mutation', + rootField: 'createOneUser', + }) + expect(() => document.validate(select, false)).not.toThrow() + }) +}) diff --git a/src/packages/client/src/runtime/query.ts b/src/packages/client/src/runtime/query.ts index 1c5e23862120..0f48d4f8ca84 100644 --- a/src/packages/client/src/runtime/query.ts +++ b/src/packages/client/src/runtime/query.ts @@ -1310,6 +1310,13 @@ function hasCorrectScalarType( if (graphQLType === 'List' && expectedType === 'List') { return true } + if ( + expectedType === 'List' && + (graphQLType === 'List' || + graphQLType === 'List') + ) { + return true + } // Int is a subset of Float if (graphQLType === 'Int' && expectedType === 'Float') {