fix: Not allowed empty PK value for update() and delete() #9837
+56
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Comment #9830 (comment)
For the event, I returned the transfer of an array IDs or
null.An attempt to return the check for incorrect PK update()/delete(). Values of
'' 0 '0' nulland the same values in the array[1 => null, 2 => '', 3 => '0',...]are invalid, they can cause SQL exception. We intercept this before executing the query and throw our DatabaseException.In this state, it only solves for the
$idpassed todelete(),update(). But we can pass the value viawhere('id', [1, 2, 3])-> update()orwhereIn('id', [1, 2, 3])-> update()and other. Therefore, I need to know whether to handle these cases or return an SQL exception to the user?Example bad SQL:
Checklist: