Skip to content

Commit

Permalink
Update test to use correct message
Browse files Browse the repository at this point in the history
Add test to validate `@@index` case
  • Loading branch information
Druue committed Nov 9, 2023
1 parent 5794fe3 commit a58ad02
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions query-engine/prisma-models/tests/datamodel_converter_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ fn converting_enums() {
// region: composite
#[test]
fn converting_composite_types_compound() {
let res = psl::parse_schema(
r#"
datasource db {
provider = "mongodb"
url = "mongodb://localhost:27017/hello"
}
model Post {
id String @id @default(auto()) @map("_id") @db.ObjectId
author User @relation(fields: [authorId], references: [id])
authorId String @db.ObjectId
attributes Attribute[]
@@index([authorId, attributes])
}
type Attribute {
name String
value String
group String
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
Post Post[]
}
"#,
);

assert!(res.is_ok());
}

#[test]
fn converting_composite_types_compound_unique() {
let res = psl::parse_schema(
r#"
datasource db {
Expand All @@ -56,7 +90,7 @@ fn converting_composite_types_compound() {
@@unique([authorId, attributes])
// ^^^^^^^^^^^^^^^^^^^^^^
// Prisma does not currently support composite types in compound indices
// Prisma does not currently support composite types in compound unique indices...
}
type Attribute {
Expand All @@ -74,7 +108,7 @@ fn converting_composite_types_compound() {

assert!(res
.unwrap_err()
.contains(r#"Prisma does not currently support composite types in compound indices, please remove "attributes" from the index. See https://pris.ly/d/mongodb-composite-compound-indices for more details"#));
.contains(r#"Prisma does not currently support composite types in compound unique indices, please remove "attributes" from the index. See https://pris.ly/d/mongodb-composite-compound-indices for more details"#));
}

#[test]
Expand Down

0 comments on commit a58ad02

Please sign in to comment.