-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(quaint): add explicit regression test for issue prisma/prisma#24072
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
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
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
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
44 changes: 44 additions & 0 deletions
44
query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_24072.rs
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,44 @@ | ||
use indoc::indoc; | ||
use query_engine_tests::*; | ||
|
||
#[test_suite(schema(schema))] | ||
mod prisma_24072 { | ||
fn schema() -> String { | ||
let schema = indoc! { | ||
r#"model Parent { | ||
#id(id, Int, @id) | ||
child Child? | ||
} | ||
model Child { | ||
#id(id, Int, @id) | ||
parent_id Int? @default(2) @unique | ||
parent Parent? @relation(fields: [parent_id], references: [id], onDelete: SetDefault) | ||
}"# | ||
}; | ||
|
||
schema.to_owned() | ||
} | ||
|
||
// Deleting the parent without cascading to the child should fail with an explicitly named constraint violation, | ||
// without any "(not available)" names. | ||
#[connector_test] | ||
async fn test_24072(runner: Runner) -> TestResult<()> { | ||
insta::assert_snapshot!( | ||
run_query!(&runner, r#"mutation { createOneParent(data: { id: 1, child: { create: { id: 1 }}}) { id }}"#), | ||
@r###"{"data":{"createOneParent":{"id":1}}}"### | ||
); | ||
|
||
assert_connector_error!( | ||
&runner, | ||
"mutation { deleteOneParent(where: { id: 1 }) { id }}", | ||
2003, | ||
CockroachDb(_) | Postgres(_) | SqlServer(_) | Vitess(_) => "Foreign key constraint violated: `Child_parent_id_fkey (index)`", | ||
MySql(_) => "Foreign key constraint violated: `parent_id`", | ||
Sqlite(_) => "Foreign key constraint violated: `foreign key`", | ||
_ => "Foreign key constraint violated" | ||
); | ||
|
||
Ok(()) | ||
} | ||
} |