Repository navigation
fix: cast Postgre batch subquery values so updateBatch() and deleteBatch() accept mixed PHP types - #10601
fix: cast Postgre batch subquery values so updateBatch() and deleteBatch() accept mixed PHP types#10601paulbalandan wants to merge 1 commit into
updateBatch() and deleteBatch() accept mixed PHP types#10601Conversation
fe8ef19 to
22146f8
Compare
22146f8 to
ef96d2b
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Mapped or qualified columns can remain uncast, while enum, domain, and array metadata can generate invalid PostgreSQL casts.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Fixes PostgreSQL batch updates/deletes with mixed PHP value types by casting subquery values to target column types.
Changes:
- Adds PostgreSQL value casting for batch operations.
- Adds live database regression tests.
- Documents the fix in the 4.7.5 changelog.
Base branch assumed to be develop. Static review performed; database validation remains with GitHub Actions.
| File | Description |
|---|---|
system/Database/Postgre/Builder.php |
Casts PostgreSQL batch subquery values. |
tests/system/Database/Live/UpdateTest.php |
Tests mixed-type batch updates. |
tests/system/Database/Live/DeleteTest.php |
Tests mixed-type batch deletes. |
user_guide_src/source/changelogs/v4.7.5.rst |
Records the bug fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| $column = array_search($key, $constraints, true); | ||
|
|
||
| return sprintf( | ||
| '%s %s', | ||
| $this->cast((string) $index, $this->getFieldType($table, is_string($column) ? $column : $key)), |
There was a problem hiding this comment.
This form does not work on develop either: the delete WHERE clause already prefixes the key with the table, so a qualified key yields "type_test"."type_test"."type_text". The example cited is the MySQL updateBatch sample. Supporting qualified mapped keys is a separate change.
…eBatch()` accept mixed PHP types
ef96d2b to
4bc33aa
Compare
michalsn
left a comment
There was a problem hiding this comment.
Casting delete constraint values to CHAR(n) can change which rows match. For example, with a CHAR(3) column, 'ABCD' is truncated to 'ABC', so deleteBatch() can delete the row containing 'ABC' even though the supplied value does not match it. The comparison should preserve the full input value.


Description
Fixes #10599
Checklist: