Skip to content

Commit

Permalink
#1969 PostgreSQL integration test for introspection warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolg42 committed Apr 2, 2020
1 parent 04af160 commit 288f620
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 19 deletions.
127 changes: 108 additions & 19 deletions cli/prisma2/__snapshots__/integrate.postgresql.test.ts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
exports['await column_name_that_becomes_empty_string.findMany({})_datamodel'] = `
generator client {
provider = "prisma-client-js"
output = "***"
}
datasource pg {
provider = "postgresql"
url = "***"
}
model column_name_that_becomes_empty_string {
// This field was commented out because of an invalid name. Please provide a valid one that matches [a-zA-Z][a-zA-Z0-9_]*
// 12345 Int? @map("12345")
field1 Int @default(autoincrement()) @id
}
model invalid_enum_value_name {
field1 Int @default(autoincrement()) @id
here_be_enum invalid_enum?
}
// The underlying table does not contain a unique identifier and can therefore currently not be handled.
// model no_unique_identifier {
// field1 Int?
// field2 Int?
// }
model unsupported_type {
field1 Int @default(autoincrement()) @id
// This type is currently not supported.
// unsupported geometric?
}
enum invalid_enum {
// $§! @map("$§!")
// 123 @map("123")
N
Y
}
`

exports['await column_name_that_becomes_empty_string.findMany({})_warnings'] = [
{
"code": 1,
"message": "These models do not have a unique identifier or id and are therefore commented out.",
"affected": [
{
"model": "no_unique_identifier"
}
]
},
{
"code": 2,
"message": "These fields were commented out because of invalid names. Please provide valid ones that match [a-zA-Z][a-zA-Z0-9_]*.",
"affected": [
{
"model": "column_name_that_becomes_empty_string",
"field": "12345"
}
]
},
{
"code": 3,
"message": "These fields were commented out because we currently do not support their types.",
"affected": [
{
"model": "unsupported_type",
"field": "unsupported",
"tpe": "geometric"
}
]
},
{
"code": 4,
"message": "These enum values were commented out because of invalid names. Please provide valid ones that match [a-zA-Z][a-zA-Z0-9_]*.",
"affected": [
{
"enm": "invalid_enum",
"value": "$§!"
},
{
"enm": "invalid_enum",
"value": "123"
}
]
}
]

exports['teams.findOne({ where: { id: 2 } })_datamodel'] = `
generator client {
provider = "prisma-client-js"
Expand Down Expand Up @@ -1069,6 +1158,25 @@ model teams {

exports['teams.findMany({ where: { token: { notIn: [] } } })_warnings'] = []

exports['users.findMany({ where: { email: \'MAX@PRISMA.IO\' } })_datamodel'] = `
generator client {
provider = "prisma-client-js"
output = "***"
}
datasource pg {
provider = "postgresql"
url = "***"
}
model users {
email String @unique
id Int @default(autoincrement()) @id
}
`

exports['users.findMany({ where: { email: \'MAX@PRISMA.IO\' } })_warnings'] = []

exports['exercises.findMany({ where: { distance: 12.213 } })_datamodel'] = `
generator client {
provider = "prisma-client-js"
Expand Down Expand Up @@ -1354,22 +1462,3 @@ model teams {
`

exports['await teams.updateMany({ data: { name: \'b\' }, where: { name: null }, }) client.teams.findMany();_warnings'] = []

exports['users.findMany({ where: { email: \'MAX@PRISMA.IO\' } })_datamodel'] = `
generator client {
provider = "prisma-client-js"
output = "***"
}
datasource pg {
provider = "postgresql"
url = "***"
}
model users {
email String @unique
id Int @default(autoincrement()) @id
}
`

exports['users.findMany({ where: { email: \'MAX@PRISMA.IO\' } })_warnings'] = []
35 changes: 35 additions & 0 deletions cli/prisma2/src/__tests__/integrate.postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,41 @@ function tests(): Test[] {
},
],
},
{
up: `
CREATE TABLE column_name_that_becomes_empty_string (
field1 serial primary key not null,
"12345" int DEFAULT NULL
);
create type invalid_enum as enum ('Y','N','123','$§!');
CREATE TABLE invalid_enum_value_name (
field1 serial primary key not null,
here_be_enum invalid_enum DEFAULT NULL
);
CREATE TABLE no_unique_identifier (
field1 int DEFAULT NULL,
field2 int DEFAULT NULL
);
CREATE TABLE unsupported_type (
field1 serial primary key not null,
unsupported polygon DEFAULT NULL
);
`,
down: `
drop table if exists column_name_that_becomes_empty_string cascade;
drop table if exists invalid_enum_value_name cascade;
drop table if exists no_unique_identifier cascade;
drop table if exists unsupported_type cascade;
`,
do: async client => {
return await client.column_name_that_becomes_empty_string.findMany({})
},
expect: [],
},
]
}

Expand Down

0 comments on commit 288f620

Please sign in to comment.