Skip to content

Commit

Permalink
#1969 SQLite 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 288f620 commit 0b26a37
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
75 changes: 75 additions & 0 deletions cli/prisma2/__snapshots__/integrate.sqlite.test.ts.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
exports['await column_name_that_becomes_empty_string.findMany({})_datamodel'] = `
generator client {
provider = "prisma-client-js"
output = "***"
}
datasource sqlite {
provider = "sqlite"
url = "***"
}
model teams {
email String @unique
id Int @id
name String @unique
}
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
}
// The underlying table does not contain a unique identifier and can therefore currently not be handled.
// model no_unique_identifier {
// This type is currently not supported.
// field1 integer key
// field2 Int?
// }
model unsupported_type {
field1 Int @default(autoincrement()) @id
// This type is currently not supported.
// unsupported binary(50)?
}
`

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": "no_unique_identifier",
"field": "field1",
"tpe": "integer key"
},
{
"model": "unsupported_type",
"field": "unsupported",
"tpe": "binary(50)"
}
]
}
]

exports['teams.findOne({ where: { id: 2 } })_datamodel'] = `
generator client {
provider = "prisma-client-js"
Expand Down
28 changes: 28 additions & 0 deletions cli/prisma2/src/__tests__/integrate.sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,34 @@ function tests(): Test[] {
},
],
},
{
up: `
CREATE TABLE \`column_name_that_becomes_empty_string\` (
\`field1\` integer primary key not null,
\`12345\` integer DEFAULT NULL
);
CREATE TABLE \`no_unique_identifier\` (
\`field1\` integer key not null,
\`field2\` integer DEFAULT NULL
);
CREATE TABLE \`unsupported_type\` (
\`field1\` integer primary key not null,
\`unsupported\` binary(50) DEFAULT NULL
);
`,
down: `
drop table if exists column_name_that_becomes_empty_string;
drop table if exists invalid_enum_value_name;
drop table if exists no_unique_identifier;
drop table if exists unsupported_type;
`,
do: async client => {
return await client.column_name_that_becomes_empty_string.findMany({})
},
expect: [],
},
]
}

Expand Down

0 comments on commit 0b26a37

Please sign in to comment.