Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@prisma | ||
migrations | ||
db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
10 changes: 10 additions & 0 deletions
10
src/packages/client/fixtures/scalarList/prisma/schema.prisma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
datasource my_db { | ||
provider = "postgres" | ||
url = env("POSTGRES_URL") | ||
} | ||
|
||
model User { | ||
id String @default(cuid()) @id | ||
name String | ||
hobbies String[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"esModuleInterop": true, | ||
"noImplicitAny": false, | ||
"lib": ["esnext"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters