Repository navigation
Adding UUIDs for rows - #3253
rjzondervan wants to merge 13 commits into
Conversation
Rows get a UUIDv7 in tables_row_sleeves with a global unique index.
Every mapper insert assigns one, and a user migration import keeps
the exported uuid when no other row uses it yet. Existing rows are
backfilled in batches by a queued background job, so the column stays
nullable until the backfill has finished.
GET, PUT and DELETE on /api/2/{tables|views}/{nodeId}/rows/{rowId}
accept an integer id or a uuid. A uuid is only looked up within the
table, or the table of the view, so a uuid of another table is not
found. Federated tables and views keep using the integer id and
reject a uuid with a 400.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Robert Zondervan <robert@conduction.nl>
Drop an unused catch variable in RowService::findViewOrFail and pass uuidOf as a first-class callable in BackfillRowUuidsTest, as the rector check asks. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
The row identifier methods were inserted between create() and its docblock, which left create() without its $data shape and @throws list and gave resolveRowId() two docblocks. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
resolveRowId() looked a uuid up in all tables when it got neither a table nor a view. The api/2 routes always pass one, but the method is public and promises a lookup within the table, so it now throws an InternalError instead, as findInNode() does. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
The uuid index is unique across all tables, so an exported uuid may only be kept when no row in any table uses it. The existing tests mocked the lookup and checked only its first argument. A new test stores the uuid in another table and resolves it through the real mapper, and the mocks now also expect no table id. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
The migration docblock said the column stays nullable until the backfill has finished, which suggested a step in this change that makes it NOT NULL. There is none: a migration that runs in the same upgrade would have to fill every uuid during that upgrade, which is what the background job avoids. Making the column NOT NULL is left to a migration in a later release, after the backfill has had a release to run. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
Each batch selected the rows without a uuid ordered by id. On PostgreSQL that walks the primary key and skips every row already filled in, so each batch got slower as the backfill went on: with half of 1M rows filled, one batch query took 138 ms after a vacuum and 425 ms before one, against 0.2 to 2 ms without the ordering. The backfill only needs some rows without a uuid, so the ordering is dropped. A full backfill of 1M rows on PostgreSQL 16 now takes 103 runs of about 1.75 s each, the same at the start and at the end. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
PUT and DELETE on /api/2/public/{token}/rows/{rowId} accept an integer
id or a uuid, like the authenticated row routes. A uuid is only looked
up within the shared table, or the table of the shared view. The rows
these routes return already carried their uuid; TablesPublicRow now
declares it, and DELETE documents its 400 for a malformed identifier.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Robert Zondervan <robert@conduction.nl>
RowService gained a RowVisibilityService constructor argument on main (#3250), so the row identifier and import tests construct it with a mock as well. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Robert Zondervan <robert@conduction.nl>
|
Both PRs indeed conflict. This PR contains one feature (public routes with uuid) that is missing in #3229, but when that merges I could reimplement that shortly. Closing this PR for now. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Upstream continues with nextcloud#3229 for the row uuid, so take out the net change of nextcloud#3253 as merged here (the diff from its merge base with main to 7d307e2). The id routes go back to main: an integer row id and no single-row GET. The slug routes share the row helpers with the id routes, so they take the integer row id again as well ('rowId' => '(\d+)'). findInNode() stays in RowService for the single-row GET by slug, with its tests in RowServiceFindInNodeTest. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Zondervan <robert@conduction.nl>
Upstream continues with nextcloud#3229 for the row uuid, so take out the net change of nextcloud#3253 (the diff from its merge base with main to b5977db). The single-row GET and the uuid addressing of the row routes go with it. The row listing keeps the node helpers it uses. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Zondervan <robert@conduction.nl>
The revert of nextcloud#3253 took findViewOrFail() with it, which the listing uses, so it comes back as a private helper. The tests construct RowService without the IDBConnection that nextcloud#3229 dropped and with the RowQueryResolver the listing added. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Zondervan <robert@conduction.nl>
Brings in the revert of nextcloud#3253 and nextcloud#3229 through the row listing. Conflicts: - RowOCSController: the single-row GET came from nextcloud#3253 and goes with the revert, together with the shape handling 3096/1 added to it; a numeric-id read of one row follows as its own commit. - RowSleeveMapper: findIdByUuid of nextcloud#3253 goes; findUuidsByIds of 3096/1 stays for now. - openapi.json and the TS types are regenerated. The controller and find-page tests that read a single row now read the listing; the findUuidsByIds tests use the sleeve helpers of nextcloud#3229. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Zondervan <robert@conduction.nl>
GET /api/2/{tables|views}/{nodeId}/rows/{rowId} returns one row of the
table or view, in the cells shape or with ?shape=object in the object
shape. The row id is the only identifier the route takes; a row outside
the table or view, or without read access to it, is not found. Federated
tables and views answer 400, as the listing does.
The single-row GET of nextcloud#3253 went with its revert; this one takes only
the numeric row id (nextcloud#3093).
Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Robert Zondervan <robert@conduction.nl>
Conflicts: - RowOCSController::updateRow keeps the shape and validation handling of the object-shape write, with the integer row id of 3096/1; the uuid lookup of the row id is gone. - RowService keeps the helpers where 3096/1 placed them and the strict validation note on create(). - RowServiceImportRowTest is gone with nextcloud#3253; RowServiceUuidTest gets the RowObjectInputConverter constructor argument. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Zondervan <robert@conduction.nl>
Closes issue #3093
Adds UUIDs to Rows as described in issue #3093.
A small summary:
tables_row_sleevesapi/2/{tables|views}/{nodeId}/rows/{rowId}. On PUT and DELETE methods this does not yet work for federated tables and federated views.This PR does not set the UUID column to
NOT NULLas these are added by a backfill.To help the reviewers, we did a number of internal reviews before posting the PR here, that we did on our reviewing-fork, and the results can be found in this draft PR.
This PR is larger than I would like it with just over 2000 LoC. However, of those 2000 lines only ~500 lines are actual production code. ~500 more lines are generated API docs and the remaining ~1000 lines are added unit tests.
🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)