Skip to content

adds support for reference datatype to node value/display value functions - #13071

Merged
chiatt merged 2 commits into
dev/8.2.xfrom
rmg/relational_view_fixes_for_reference_data
Oct 30, 2026
Merged

chiatt merged 2 commits into
dev/8.2.xfrom
rmg/relational_view_fixes_for_reference_data

Conversation

@robgaston

Copy link
Copy Markdown
Member

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description of Change

__arches_get_node_value_sql had no mapping for the reference datatype, so relational views typed reference nodes as text. Reading a reference node through the view gave a JSON string instead of jsonb. Writing through the view was worse: __arches_get_json_data_for_view calls to_json() on the column, so a value inserted or updated through the view was stored in the tile as a quoted JSON string, not an array.

This PR:

  • maps reference to jsonb in __arches_get_node_value_sql, which fixes both reading and writing.
  • adds a reference branch to __arches_get_node_display_value. It returns the item labels joined with , and uses the existing __arches_controlled_lists_get_reference_label_list helper from the controlled_lists extension (migration 0006). Reference nodes can only exist when that extension is installed, so core only calls the helper for those nodes.
  • adds migration 13064_reference_datatype_relational_views, generated through django_migrate_sql from the .sql files.

Note on display values: the SQL helper looks up the current labels in the list item tables. ReferenceDataType.get_display_value uses the copy of the labels saved in the tile data. If a list item is renamed after it has been used in a tile, the two will show different labels.

Note on the error in the issue: the column ... does not exist error came from a local override of __arches_get_node_value_sql that still named columns __arches_slugify(node.name). Since #12773, views name their columns by node alias. Projects that override this function to work around the missing reference mapping should drop the override after upgrading. (@ekansa)

Issues Solved

Closes #13064

Checklist

  • I targeted one of these branches:
    • dev/8.2.x (under development): features, bugfixes not covered below
    • dev/8.1.x (main support): regressions, crashing bugs, security issues, major bugs in new features
    • dev/7.6.x (extended support): major security issues, data loss issues
  • I added a changelog in arches/releases
  • I submitted a PR to arches-docs (if appropriate)
  • Unit tests pass locally with my changes
  • I added tests that prove my fix is effective or that my feature works
  • My test fails on the target branch

Accessibility Checklist

Developer Guide

Topic Changed Retested
Color contrast
Form fields
Headings
Links
Keyboard
Responsive Design
HTML validation

Further comments

New tests in tests/models/relational_data_model_tests.py:

  • test_reference_column_round_trips_as_jsonb checks that the view column is jsonb and that a reference value inserted through the view is stored in the tile as an array.
  • test_reference_display_value checks that __arches_get_node_display_value returns First, Second for two references.

Both tests fail against dev/8.2.x and pass with this change.

The fixture node sets pgDatatype: jsonb, which skips the datatype mapping entirely, so the tests clear the node's config when switching it to reference.

@ekansa ekansa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it works! I will need to run the ETL to fully check.

When I create the relational views using this branch nodes with the Arches reference datatype correctly have the PostgreSQL jsonb datatype. The relation views for the models create without error.

@ekansa

ekansa commented Oct 27, 2026

Copy link
Copy Markdown

@robgaston I checked and the this update also works for ETL workflow. I confirmed can INSERT and UPDATE Arches reference datatype data now too.

@chiatt
chiatt merged commit e7cd66d into dev/8.2.x Oct 30, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this to ✅ Done in pipeline Oct 30, 2026
@chiatt
chiatt deleted the rmg/relational_view_fixes_for_reference_data branch October 30, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Problems with relational views and nodes with controlled list item datatypes dev/8.2

3 participants