Repository navigation
fix(databases): allow updates of rows that predate a required column - #14202
Conversation
Making a column required left older rows null. Single-row updates merge that null into the document and then reject it as a missing attribute, so every partial update failed. An unchanged null is validated as optional. Creates, and updates that clear a value already set, still fail. Fixes #14175
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Remove the renamed copy of utopia-php/database's Structure validator, the subclass that shadowed it through the autoloader, the classmap, Pint and PHPStan exclusions it needed, and its hash-locked unit test. The required-null check belongs in the library's Structure validator.
Assert a partial update and an upsert of a row that predates a required column succeed and leave that column null.
|
@hansi-codes review |
🟢 Tier S · Ready to merge
The PR upgrades utopia-php/database to 7.4.1 to allow updates of existing rows whose required column is already null. It adds shared API regression coverage for partial updates, upserts, filling the column, and rejection of missing or cleared required values.
📂 Walkthrough · 3
✅ Fixed since the last review · 1
Reviewed |
…n-partial-update-6f42 # Conflicts: # composer.json # composer.lock
|
Review complete. No issues found — approved ✅. This PR bumps the
Reviewed commit: 1b47448 |
What does this PR do?
Fixes #14175. A row stored before a column became required holds null for it. That happens when a column is made required, or when a required column is added to a table that already has rows. Row updates and upserts validate the merged row, so every update of such a row failed with
Missing required attribute, even when the update never touched the column.The fix is in the
Structurevalidator ofutopia-php/database(utopia-php/database#1000, released in 7.4.1), and this PR bumps the dependency to^7.4.1. A required column that the stored row already holds as null may stay null. Setting it still works. Clearing a set value, and creating a row without it, still fail.Test Plan
testUpdateRequiredAttributeAllowsPartialUpdate(TablesDB and legacy Databases) creates rows and makes an empty column required. It then checks that updating or upserting another column returns 200 and leaves the column null, that setting the column returns 200, and that clearing the column or creating a row without it returns 400.Run locally against an API container with the patched validator, both
TablesDBCustomServerTestandLegacyCustomServerTestpass. With the current validator the test fails at the partial update, which returns 400.Related PRs and Issues
Checklist