Skip to content

Commit

Permalink
tests(client): add query null on runtime blog
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Aug 20, 2020
1 parent 700d525 commit 76272d7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,35 @@ describe('minimal where transformation', () => {
}"
`)
})

test('one-to-one realtion where null', () => {
const transformedDocument = getTransformedDocument({
where: {
profile: {
bio: { not: null },
},
},
})

expect(transformedDocument).toMatchInlineSnapshot(`
"query {
findManyUser(where: {
profile: {
is: {
bio: {
not: null
}
}
}
}) {
id
email
name
json
}
}"
`)
})
})

function getTransformedDocument(select) {
Expand Down
Binary file modified src/packages/client/src/__tests__/runtime-tests/blog/dev.db
Binary file not shown.
10 changes: 10 additions & 0 deletions src/packages/client/src/__tests__/runtime-tests/blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ module.exports = async () => {
}
}

// relation query where not null
const relationWhereNotNull = await db.user.findMany({
where: {
profile: {
bio: { not: null },
},
},
})
assert.deepStrictEqual(relationWhereNotNull, [])

db.$disconnect()
}

Expand Down
14 changes: 11 additions & 3 deletions src/packages/client/src/__tests__/runtime-tests/blog/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
datasource db {
provider = "sqlite"
url = "sqlite:dev.db"
url = "file:./dev.db"
default = true
}

generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
}

// / User model comment
Expand All @@ -15,6 +15,14 @@ model User {
// / name comment
name String?
posts Post[]
profile Profile?
}

model Profile {
id String @default(cuid()) @id
bio String?
user User @relation(fields: [userId], references: [id])
userId String @unique
}

model Post {
Expand All @@ -24,6 +32,6 @@ model Post {
published Boolean
title String
content String?
authorId String? @map("author")
authorId String? @map("author")
author User? @relation(fields: [authorId], references: [id])
}
22 changes: 22 additions & 0 deletions src/packages/client/src/__tests__/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ describe('select validation', () => {
~~~~~
? posts?: true,
? email?: true,
? profile?: true,
? json?: true
}
}
Expand All @@ -147,6 +148,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`age_gt\` in where.AND.0.age_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -158,6 +160,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`this_is_completely_arbitrary\` in where.AND.0.this_is_completely_arbitrary for type UserWhereInput. Available args:
Expand All @@ -170,6 +173,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`age_gt\` in where.AND.1.age_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -181,6 +185,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`id_endsWith\` in where.AND.1.id_endsWith for type UserWhereInput. Available args:
Expand All @@ -193,6 +198,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`name_contains\` in where.AND.1.name_contains for type UserWhereInput. Available args:
Expand All @@ -205,6 +211,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`name_gt\` in where.AND.1.name_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -216,6 +223,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`name_in\` in where.AND.1.name_in for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -227,6 +235,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`age_gt\` in where.AND.1.AND.0.age_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -238,6 +247,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`id_endsWith\` in where.AND.1.AND.0.id_endsWith for type UserWhereInput. Available args:
Expand All @@ -250,6 +260,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Invalid value 'asd' of type String for field name on model User. Expected either true or false.
Expand Down Expand Up @@ -313,6 +324,7 @@ describe('select validation', () => {
~~~~~
? posts?: true,
? email?: true,
? profile?: true,
? json?: true
}
}
Expand All @@ -326,6 +338,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`age_gt\` in where.AND.0.age_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -337,6 +350,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`this_is_completely_arbitrary\` in where.AND.0.this_is_completely_arbitrary for type UserWhereInput. Available args:
Expand All @@ -349,6 +363,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`age_gt\` in where.AND.1.age_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -360,6 +375,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`id_endsWith\` in where.AND.1.id_endsWith for type UserWhereInput. Available args:
Expand All @@ -372,6 +388,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`name_contains\` in where.AND.1.name_contains for type UserWhereInput. Available args:
Expand All @@ -384,6 +401,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`name_gt\` in where.AND.1.name_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -395,6 +413,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`name_in\` in where.AND.1.name_in for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -406,6 +425,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`age_gt\` in where.AND.1.AND.0.age_gt for type UserWhereInput. Did you mean \`name\`? Available args:
Expand All @@ -417,6 +437,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Unknown arg \`id_endsWith\` in where.AND.1.AND.0.id_endsWith for type UserWhereInput. Available args:
Expand All @@ -429,6 +450,7 @@ describe('select validation', () => {
email?: String | StringFilter
name?: String | StringNullableFilter | null
posts?: PostListRelationFilter
profile?: ProfileWhereInput
json?: Json | JsonNullableFilter | null
}
Invalid value 'asd' of type String for field name on model User. Expected either true or false.
Expand Down
8 changes: 8 additions & 0 deletions src/packages/client/src/fixtures/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ model User {
/// name comment
name String?
posts Post[]
profile Profile?
json Json?
}
model Profile {
id String @default(cuid()) @id
bio String?
user User @relation(fields: [userId], references: [id])
userId String @unique
}
model Post {
id String @default(cuid()) @id
createdAt DateTime @default(now())
Expand Down

0 comments on commit 76272d7

Please sign in to comment.