forked from prisma/prisma-engines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(joins): relations should not collide with mapped scalar fields (p…
- Loading branch information
Showing
9 changed files
with
81 additions
and
30 deletions.
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
52 changes: 52 additions & 0 deletions
52
query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_22971.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,52 @@ | ||
use indoc::indoc; | ||
use query_engine_tests::*; | ||
|
||
#[test_suite(schema(schema))] | ||
mod prisma_22971 { | ||
fn schema() -> String { | ||
let schema = indoc! { | ||
r#"model User { | ||
#id(id, Int, @id, @map("hello")) | ||
updatedAt String @default("now") @map("updated_at") | ||
postId Int? @map("post") | ||
post Post? @relation("User_post", fields: [postId], references: [id]) | ||
} | ||
model Post { | ||
#id(id, Int, @id, @map("world")) | ||
updatedAt String @default("now") @map("up_at") | ||
from_User_post User[] @relation("User_post") | ||
}"# | ||
}; | ||
|
||
schema.to_owned() | ||
} | ||
|
||
// Ensures that mapped fields are correctly resolved, even when there's a conflict between a scalar field name and a relation field name. | ||
#[connector_test] | ||
async fn test_22971(runner: Runner) -> TestResult<()> { | ||
run_query!(&runner, r#"mutation { createOnePost(data: { id: 1 }) { id } }"#); | ||
run_query!( | ||
&runner, | ||
r#"mutation { createOneUser(data: { id: 1, postId: 1 }) { id } }"# | ||
); | ||
|
||
insta::assert_snapshot!( | ||
run_query!(&runner, r#"{ | ||
findManyUser { | ||
id | ||
updatedAt | ||
post { | ||
id | ||
updatedAt | ||
} | ||
} | ||
}"#), | ||
@r###"{"data":{"findManyUser":[{"id":1,"updatedAt":"now","post":{"id":1,"updatedAt":"now"}}]}}"### | ||
); | ||
|
||
Ok(()) | ||
} | ||
} |
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
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
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