-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generate m2m connects and disconnects in the compiler #5153
Conversation
WASM Query Engine file Size
|
CodSpeed Performance ReportMerging #5153 will not alter performanceComparing Summary
|
3f22a25
to
5aecb49
Compare
expr: Box::new(expr), | ||
}) | ||
} else { | ||
Ok(expr) | ||
} | ||
} | ||
} | ||
|
||
fn generate_projected_dependency_name(source: NodeRef, field: &SelectedField) -> String { | ||
format!("{}${}", source.id(), field.prisma_name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even when we have just one edge, doing this instead of shadowing makes the query plan much nicer to read 👍
// TODO: we ignore chunking for now | ||
let linking_scalars = field.related_field().left_scalars(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move it inside the if let
statement below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noticed that field.related_field().left_scalars()
was being called twice in this function so I extracted it into a single call instead
expression: pretty | ||
input_file: query-compiler/query-compiler/tests/data/create-m2m.json | ||
--- | ||
let 0 = unique (query «INSERT INTO "public"."User" ("email") VALUES ($1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR but I'm only now realizing we're missing the check if the query graph is transactional, and the corresponding query plan node. Should be easy to add.
in execute «INSERT INTO "public"."_CategoryToPost" ("B","A") VALUES | ||
($1,$2) ON CONFLICT DO NOTHING» | ||
params [var(1$id as Int), var(2$id as Int)]; | ||
let 4 = let 0$id = mapField id (get 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[unrelated to this PR] We should later introduce optimization passes and, among them, eliminate duplicate mapField
expressions (here we even already have it in scope). Although they are cheap in this case (since 0
is unique
), in general we may be mapping a long list.
= $1 OFFSET $2» | ||
params [var(@parent$id as Int), | ||
const(BigInt(0))]) on left.(id) = right.(userId) as posts | ||
in get 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[unrelated to this PR] rewriting let x = y in get x
to y
is also an obvious candidate for optimization, although here it's mostly cosmetic
)) => child_column.in_selection(val.clone().decorate( | ||
Some("prisma-comma-repeatable-start"), | ||
Some("prisma-comma-repeatable-end"), | ||
)), | ||
_ => child_column.in_selection(values), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this special handling for ValueType::Var
in in_selection
should be in quaint itself and not on this level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.so_that(parent_id_criteria.and(child_id_criteria)) | ||
.add_traceparent(self.context.traceparent); | ||
|
||
let query = write::delete_relation_table_records(&field, parent_id, child_ids, &self.context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Closes ORM-561.