Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulk_update() on I18n_JSON fields fails with heterogenous values #10619

Open
jacobtylerwalls opened this issue Feb 20, 2024 · 1 comment
Open
Labels
Type: Bug Something isn't working

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Feb 20, 2024

See skipped unittest test_bulk_update_heterogenous_values() from #10620:

@unittest.skip("https://github.com/archesproject/arches/issues/10619")
def test_bulk_update_heterogenous_values(self):
new_configs = [
I18n_JSON({
"en": "some",
"zh": "json",
}),
I18n_JSON({}),
None,
]
for_bulk_update = []
for i, dt in enumerate(DDataType.objects.all()[:3]):
dt.defaultconfig = new_configs[i]
for_bulk_update.append(dt)
DDataType.objects.bulk_update(for_bulk_update, fields=["defaultconfig"])
for i, obj in enumerate(for_bulk_update):
new_config_as_string = str(new_configs[i])
with self.subTest(new_config=new_config_as_string):
obj.refresh_from_db()
self.assertEqual(str(obj.defaultconfig), new_config_as_string)

Fails with:

======================================================================
FAIL: test_bulk_update_heterogenous_values (tests.localization.field_tests.I18nJSONFieldBulkUpdateTests.test_bulk_update_heterogenous_values) (new_config='{}')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jwalls/prj/arches/tests/localization/field_tests.py", line 399, in test_bulk_update_heterogenous_values
    self.assertEqual(str(obj.defaultconfig), new_config_as_string)
AssertionError: '{"en": "some", "zh": "json"}' != '{}'
- {"en": "some", "zh": "json"}
+ {}


======================================================================
FAIL: test_bulk_update_heterogenous_values (tests.localization.field_tests.I18nJSONFieldBulkUpdateTests.test_bulk_update_heterogenous_values) (new_config='None')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jwalls/prj/arches/tests/localization/field_tests.py", line 399, in test_bulk_update_heterogenous_values
    self.assertEqual(str(obj.defaultconfig), new_config_as_string)
AssertionError: '{"en": "some", "zh": "json"}' != 'None'
- {"en": "some", "zh": "json"}
+ None


----------------------------------------------------------------------
Ran 19 tests in 2.432s

FAILED (failures=2)
@jacobtylerwalls jacobtylerwalls added the Type: Bug Something isn't working label Feb 20, 2024
@jacobtylerwalls
Copy link
Member Author

This might be something that goes away when the underlying issue in Django is solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant