Skip to content

fix(database): detect wrapped Relation field types - #322

Merged
kkopanidis merged 1 commit into
ui-rewritefrom
fix/schema-relation-type-detection
Sep 9, 2026
Merged

fix(database): detect wrapped Relation field types#322
kkopanidis merged 1 commit into
ui-rewritefrom
fix/schema-relation-type-detection

Conversation

@JohnChantz

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the master branch
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx, where "xxx" is the issue number)

Other information:

In Database → Models → schema fields, array relations often showed as String instead of Relation, with no related-model picker. Saving that view would persist { type: "String" } and drop the relation.

Scalar relations ({ type: "Relation", model: "User" }) already worked. The miss was Conduit’s wrapped array form, common in production schemas:

{
  "type": [{ "type": "Relation", "model": "Team" }]
}

The editor now unwraps that shape (and { type: ["Relation"], model }) and treats a string model as Relation. The document form uses the same parser, so those fields get the relation picker instead of a text input. Saving still writes the canonical [ { type: "Relation", model } ] array.

Test plan

  • pnpm test:schema-fields — 9 cases covering scalar Relation, both array encodings, String arrays, Group, and missing type
  • Open a model whose fields use { type: [{ type: "Relation", model }] } (e.g. sharedWithTeams) and confirm type is Relation, model picker is filled, array is on
  • Confirm a scalar Relation field is unchanged
  • Confirm { type: ["String"] } stays String with array on
  • In the data explorer, those relation fields use the document picker, not a plain text input

Could not exercise the UI locally in this pass (no running admin server).

Array relations stored as { type: [{ type: Relation, model }] }
were shown as String, so saving could drop the relation.
@kkopanidis
kkopanidis merged commit 2f9cf22 into ui-rewrite Sep 9, 2026
3 checks passed
@kkopanidis
kkopanidis deleted the fix/schema-relation-type-detection branch September 9, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants