-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(qe): make
UpdateRecord::WithSelection
nodes return `RecordSelec…
…tion` (#4508) Query graph nodes that are not result nodes and fulfill the requirements of other nodes don't inherently need names because their results aren't serialized. However, we still need some name to be able to build RecordSelection because it's required there. Previously the update node with selection that has no name would return a QueryResult::Id instead of QueryResult::RecordSelection to work around that, but it caused problems as the query interpreter relied on QueryResult::Id being the primary identifier and not arbitrary fields. This PR makes the name required for UpdateRecord::WithSelection and provides a stub name when the node doesn't directly correspond to the client's query. This is consistent with other intermediate nodes that need to build RecordSelection. Some of them use constant placeholder names (like find_children_by_parent for RelatedRecordsQuery), some of them use empty strings (e.g. CreateRecord does this). I chose an empty string because it needs to be owned here and an empty String::new() doesn't allocate memory, and the specific value doesn't matter anyway because there's likely not even a way to observe this name (it's not used in Display and ToGraphviz impls for UpdateRecord). Fixes: prisma/prisma#21182
- Loading branch information
Showing
6 changed files
with
110 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ in | |
nodejs.pkgs.pnpm | ||
|
||
jq | ||
graphviz | ||
wasm-bindgen-cli | ||
wasm-pack | ||
]; | ||
|
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
98 changes: 98 additions & 0 deletions
98
query-engine/connector-test-kit-rs/query-engine-tests/tests/new/regressions/prisma_21182.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,98 @@ | ||
use query_engine_tests::*; | ||
|
||
/// Regression test for https://github.com/prisma/prisma/issues/21182 | ||
#[test_suite(schema(schema))] | ||
mod regression { | ||
use indoc::indoc; | ||
|
||
fn schema() -> String { | ||
indoc! {r#" | ||
model User { | ||
#id(id, Int, @id) | ||
email String @unique | ||
name String? | ||
roleId Int | ||
role Role @relation(fields: [roleId], references: [id]) | ||
} | ||
model Role { | ||
#id(id, Int, @id) | ||
name String | ||
users User[] | ||
tagId Int? | ||
tag Tag? @relation(fields: [tagId], references: [id]) | ||
} | ||
model Tag { | ||
#id(id, Int, @id) | ||
name String | ||
roles Role[] | ||
} | ||
"#} | ||
.to_owned() | ||
} | ||
|
||
#[connector_test] | ||
async fn query_with_normalized_dependencies(runner: Runner) -> TestResult<()> { | ||
run_query!( | ||
runner, | ||
indoc! {r#" | ||
mutation { | ||
createOneUser ( | ||
data: { | ||
id: 1, | ||
email: "[email protected]", | ||
role: { | ||
create: { | ||
id: 1, | ||
name: "ADMIN", | ||
tag: { | ||
create: { | ||
id: 1, | ||
name: "cs" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
) { | ||
id, | ||
email, | ||
roleId | ||
} | ||
} | ||
"#} | ||
); | ||
|
||
run_query!( | ||
runner, | ||
indoc! {r#" | ||
mutation { | ||
updateOneUser( | ||
where: { | ||
email: "[email protected]", | ||
}, | ||
data: { | ||
role: { | ||
update: { | ||
data: { | ||
tag: { | ||
disconnect: true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
) { | ||
id, | ||
email, | ||
roleId | ||
} | ||
} | ||
"#} | ||
); | ||
|
||
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