-
Notifications
You must be signed in to change notification settings - Fork 247
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(deleteMany): add limit option to deleteMany #5105
Conversation
CodSpeed Performance ReportMerging #5105 will not alter performanceComparing Summary
|
WASM Query Engine file Size
|
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.
Example update of a snapshot:
7006327 | {
7006328 | "name": "deleteManywebsite_redirect",
7006329 | "args": [
7006330 | {
7006331 | "name": "where",
7006332 | "isRequired": false,
7006333 | "isNullable": false,
7006334 | "inputTypes": [
7006335 | {
7006336 | "type": "website_redirectWhereInput",
7006337 | "namespace": "prisma",
7006338 | "location": "inputObjectTypes",
7006339 | "isList": false
7006340 | }
7006341 | ]
7006342 |+ },
7006343 |+ {
7006344 |+ "name": "limit",
7006345 |+ "isRequired": false,
7006346 |+ "isNullable": false,
7006347 |+ "inputTypes": [
7006348 |+ {
7006349 |+ "type": "Int",
7006350 |+ "location": "scalar",
7006351 |+ "isList": false
7006352 |+ }
7006353 |+ ]
7006354 | }
7006355 | ],
7006356 | "isNullable": false,
7006357 | "outputType": {
7006358 | "type": "AffectedRowsOutput",
7006359 | "namespace": "prisma",
7006360 | "location": "outputObjectTypes",
7006361 | "isList": false
7006362 | }
7006363 | },
4d10b18
to
90b30b7
Compare
builder.limit = limit; | ||
|
||
let builder = builder.with_model_projection(id_field)?; |
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.
What happens to the first builder
once that variable is aliased in line 324? Is the .limit
field preserved? If that's the case, shouldn't these two lines be swapped to make the resulting code semantics more intuitive and apparent?
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.
Yes it is preserved. I am not sure how moving the limit statement down improves the semantics. Esp. considering the builder.joins
etc assignments in the lines above.
Technically line 324 can also be simply builder = builder.with_model_projection(id_field)?;
(no let
).
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 am not sure how moving the limit statement down improves the semantics.
It doesn't, but it makes it clearer to the human reader that the.limit
field is preserved for the secondbuilder
shadowed variable
Technically line 324 can also be simply
builder = builder.with_model_projection(id_field)?;
(nolet
).
I'm sure there are reasons for that declaration that rescopes the secondbuilder
. Let's keep it that way unless we have a compelling argument to not do so :)
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.
Ok. Moved it but also had to make the second builder var now mutable.
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.
Late to the party here but I'd personally prefer to shadow the previous binding rather than make it mutable in cases like these. In this specific case a new immutable binding to replace the old mutable one looks intentional to limit the scope of mut
only to the few lines where we need to assign some fields.
This PR aims to implement a
limit
param ondeleteMany
operations as requested in prisma/prisma#6957.For now it uses subqueries for all SQL databases to achieve this although some databases (e.g. MySQL) support a more native
LIMIT
statement as well.I decided to go with the
limit
naming for this option instead of the existingtake
naming used for select queries. For me this is semantically more fitting.