Skip to content

Commit 096a111

Browse files
committed
perf(query-compiler): add m2m pruning support helpers
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent be5b268 commit 096a111

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

query-compiler/core/src/query_graph_builder/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ impl From<DataOperation> for String {
334334
#[serde(into = "String")]
335335
pub(crate) enum DependentOperation {
336336
NestedUpdate,
337-
DisconnectRecords,
338337
FindRecords { model: String },
339338
InlineRelation { model: String },
340339
UpdateInlinedRelation { model: String },
@@ -347,10 +346,6 @@ impl DependentOperation {
347346
Self::NestedUpdate
348347
}
349348

350-
pub fn disconnect_records() -> Self {
351-
Self::DisconnectRecords
352-
}
353-
354349
pub fn find_records(model: &Model) -> Self {
355350
Self::FindRecords {
356351
model: model.name().to_owned(),
@@ -386,7 +381,6 @@ impl fmt::Display for DependentOperation {
386381
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
387382
match self {
388383
Self::NestedUpdate => write!(f, "perform a nested update"),
389-
Self::DisconnectRecords => write!(f, "disconnect existing child records"),
390384
Self::FindRecords { model } => write!(f, "find '{model}' record(s)"),
391385
Self::InlineRelation { model } => write!(f, "inline the relation on '{model}' record(s)"),
392386
Self::UpdateInlinedRelation { model } => {

query-compiler/core/src/query_graph_builder/write/nested/set_nested.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use super::*;
22
use crate::{
33
ParsedInputValue,
44
inputs::{
5-
DisconnectChildrenInput, DisconnectParentInput, IfInput, LeftSideDiffInput, RightSideDiffInput,
6-
UpdateManyRecordsSelectorsInput, UpdateOrCreateArgsInput,
5+
IfInput, LeftSideDiffInput, RightSideDiffInput, UpdateManyRecordsSelectorsInput, UpdateOrCreateArgsInput,
76
},
87
query_graph::*,
98
};

query-compiler/query-structure/src/model.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ impl Model {
2020
.into()
2121
}
2222

23+
pub fn single_primary_identifier_scalar(&self) -> Option<ScalarFieldRef> {
24+
let mut ids = self.primary_identifier_scalars();
25+
let id = ids.next()?;
26+
27+
if ids.next().is_some() {
28+
return None;
29+
}
30+
31+
Some(self.dm.clone().zip(ScalarFieldId::InModel(id)))
32+
}
33+
2334
fn primary_identifier_scalars(&self) -> impl Iterator<Item = psl::parser_database::ScalarFieldId> + use<'_> {
2435
match self.walker().required_unique_criterias().next() {
2536
Some(unique) => Either::Left(unique.fields().map(|f| {

0 commit comments

Comments
 (0)