Skip to content

Commit 276f746

Browse files
authored
Handle for tile_data is None (#13109)
* Handle for tile_data is None * a little refactor * Add test * Changelog entry
1 parent 09cb892 commit 276f746

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎arches/extensions/querysets/querysets.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ def _set_aliased_data(self):
348348
continue
349349
datatype_instance = DataTypeFactory().get_instance(node.datatype)
350350
tile_data = datatype_instance.get_tile_data(tile)
351+
if tile_data is None:
352+
tile_data = tile.data if tile.data is not None else {}
351353
node_value = tile_data.get(str(node.pk))
352354
if node_value is None:
353355
# Datatype methods assume tiles always have all keys, but we've

‎releases/8.2.0.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
- Fix geometry saves failing when a feature id is not a valid UUID; the map editor now assigns UUIDs to drawn features and non-UUID ids are replaced on save [#12913](https://github.com/archesproject/arches/issues/12913)
7575
- Remove the Bootstrap 3 dependency, along with the unfixable advisories in its JavaScript, by vendoring its stylesheet and reimplementing the four behaviours arches used [#12936](https://github.com/archesproject/arches/pull/12936)
7676
- Fix nondeterministic tile ordering during resource copy by ordering tiles by `sortorder`/`tileid` [#PR](https://github.com/archesproject/arches/pull/PR)
77+
- Prevent error in querysets when tile has no auth or provisional data [#13109](https://github.com/archesproject/arches/pull/13109)
7778
- Fix malformed tile Excel exports that failed on import: `sortorder`, `provisionaledits` and `nodegroup_id` were written once per node instead of once per tile, so any empty node value left a stray trailing value (including the nodegroup id) behind in a node column [#PR](https://github.com/archesproject/arches/pull/PR)
7879
- Fix Bulk Data Manager imports reporting success when saving the data failed: `manage.py etl` printed "succeeded", and uploads small enough to be processed straight away showed no error [#12946](https://github.com/archesproject/arches/pull/12946)
7980
- Fix `ChunkLoadError` and `Unknown component` errors after a development rebuild: webpack 5.105.4 could keep the previous build's chunk filenames in its runtime, so pages requested chunk files that no longer existed; webpack is upgraded to 5.112.0 [#12998](https://github.com/archesproject/arches/issues/12998)

‎tests/extensions/querysets/test_internals.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from arches.app.models.models import TileModel
12
from arches.extensions.querysets.models import TileTree
23
from arches.extensions.querysets.utils.tests import GraphTestCase
34

@@ -47,3 +48,20 @@ def test_get_tiles_with_explicit_nodes_arg_decodes_only_those_nodes(self):
4748
self.assertTrue(hasattr(tile.aliased_data, self.string_node_1.alias))
4849
self.assertFalse(hasattr(tile.aliased_data, self.number_node_1.alias))
4950
self.assertFalse(hasattr(tile.aliased_data, self.boolean_node_1.alias))
51+
52+
def test_get_tiles_with_empty_tile_data(self):
53+
"""A tile with no authoritative or provisional data makes the datatype's
54+
get_tile_data() return None; nodes should decode to None instead of
55+
raising AttributeError."""
56+
TileModel.objects.filter(pk=self.cardinality_1_tile.pk).update(
57+
data={}, provisionaledits=None
58+
)
59+
tile = TileTree.get_tiles(
60+
graph_slug="datatype_lookups",
61+
nodegroup_alias="datatypes_1",
62+
resource_ids=[self.resource_42.pk],
63+
depth=0,
64+
).get(pk=self.cardinality_1_tile.pk)
65+
66+
self.assertIsNone(getattr(tile.aliased_data, self.string_node_1.alias))
67+
self.assertIsNone(tile.data[str(self.string_node_1.pk)])

0 commit comments

Comments
 (0)