Repository navigation
fix(tablesdb): move relationship column update to columns/relationship/:key - #13822
Conversation
…p/:key The relationship column update was the only one of the 18 column update routes shaped columns/:key/<type> instead of columns/<type>/:key. Make it match its siblings and keep the shipped path working as an httpAlias, the same treatment the equivalent Databases attributes route already has. The e2e URL helper no longer special-cases relationship, so the existing relationship PATCH assertions in DatabasesBase now exercise the canonical path on the TablesDB suites. MigrationsBase keeps PATCHing the old path as a raw literal, which now covers the alias.
|
| $resource = $this->getSchemaResource(); | ||
| $base = "{$this->getContainerUrl($databaseId, $containerId)}/{$resource}"; | ||
| // For relationship updates, the URL pattern is /attributes/{key}/relationship | ||
| // For other attribute updates, the URL pattern is /attributes/{type}/{key} | ||
| if ($type === 'relationship' && $key) { | ||
| $base .= "/{$key}/{$type}"; | ||
| } else { | ||
| if ($type) { | ||
| $base .= "/{$type}"; | ||
| } | ||
| if ($key) { | ||
| $base .= "/{$key}"; | ||
| } | ||
| if ($type) { | ||
| $base .= "/{$type}"; | ||
| } | ||
| if ($key) { | ||
| $base .= "/{$key}"; |
There was a problem hiding this comment.
Routing Regression Lacks Coverage
The updated tests exercise the canonical relationship route and its legacy alias, but not the collision this change is meant to fix. Add an observable E2E test that creates a string column keyed relationship, PATCHes /columns/string/relationship, and verifies that the string-column update persisted. Without this coverage, the alias could regain precedence and dispatch the request to the wrong action without a test failing.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Traits/DatabasesUrlHelpers.php
Line: 27-33
Comment:
**Routing Regression Lacks Coverage**
The updated tests exercise the canonical relationship route and its legacy alias, but not the collision this change is meant to fix. Add an observable E2E test that creates a string column keyed `relationship`, PATCHes `/columns/string/relationship`, and verifies that the string-column update persisted. Without this coverage, the alias could regain precedence and dispatch the request to the wrong action without a test failing.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…routes A column keyed `relationship` is the one key where the legacy `columns/:key/relationship` alias and the typed `columns/<type>/:key` routes describe the same URL. The router resolves that URL through the alias, so the request lands on the relationship update keyed `string` rather than the string update keyed `relationship`. Nothing covered that overlap, so a change to either path could silently move the dispatch. Assert the resolution both surfaces actually have.
There was a problem hiding this comment.
This test hard-codes the router’s current first-registration precedence and requires the known broken 404 response instead of testing an API contract users should rely on. It would fail if routing were improved so the string-column update succeeded, while passing as long as this defect remains. The repository requires tests to assert observable behavior rather than mirror implementation details, so this test must be replaced before merging with compatibility coverage for the canonical relationship route and legacy alias.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Databases/DatabasesBase.php
Line: 1865-1878
Comment:
**Test Freezes Broken Routing**
This test hard-codes the router’s current first-registration precedence and requires the known broken 404 response instead of testing an API contract users should rely on. It would fail if routing were improved so the string-column update succeeded, while passing as long as this defect remains. The repository requires tests to assert observable behavior rather than mirror implementation details, so this test must be replaced before merging with compatibility coverage for the canonical relationship route and legacy alias.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

What does this PR do?
The relationship column update was the only one of the 18 TablesDB column update routes shaped
columns/:key/<type>instead ofcolumns/<type>/:key. This makes it match its siblings and keeps the shipped path working as anhttpAlias, the same treatment the equivalent Databases attributes route already has.Correction to an earlier version of this description. It claimed this also fixed the collision where a column literally named
relationshipwas unreachable via its typed route. It does not, and I should not have asserted that without checking. Verified empirically by registering every real route and callingRouter::matchdirectly:/columns/string/relationshipkey="string"/columns/relationship/:keykey/columns/:key/relationshipkeyRouter::matchenumerates param-position combinations in first-registered order and takes the first hit. The alias/columns/:key/relationshiphas params at indices {2,4,6};/columns/string/:keyhas {2,4,7}. Index 6 is registered first (byaccount.php's/v1/account/sessions/oauth2/callback/:provider/:projectId, before any module loads), so the alias always wins. That is unfixable here while both paths must remain routable — the two shapes are genuinely ambiguous for exactly the keyrelationship, and the alias has to stay because TablesDB already shipped with it.So this is a consistency fix only: canonical path added, legacy path preserved.
Test Plan
composer linton all changed files →{"tool":"pint","result":"passed"}each.DatabasesBasenow exercise the canonical path.MigrationsBasekeeps PATCHing the old path as a raw literal, covering the alias.testUpdateRelationshipAttributeAliasPrecedence, which pins the collision as it actually behaves (the typed route 404s for a column namedrelationship) so a future change to alias precedence is a visible test failure rather than a silent shift.Not run: no e2e executed here (no Docker stack). CI should cover
tests/e2e/Services/TablesDBandtests/e2e/Services/Databaseswith--filter=testOneToManyRelationship, plustests/e2e/Services/Migrations --filter=Relationship.Related PRs and Issues
Checklist