udata 10.8.2.dev36980__py2.py3-none-any.whl → 10.8.2.dev37001__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of udata might be problematic. Click here for more details.

Files changed (24) hide show
  1. udata/commands/db.py +22 -9
  2. udata/static/chunks/{10.471164b2a9fe15614797.js → 10.8ca60413647062717b1e.js} +3 -3
  3. udata/static/chunks/{10.471164b2a9fe15614797.js.map → 10.8ca60413647062717b1e.js.map} +1 -1
  4. udata/static/chunks/{11.55ab79044cda0271b595.js → 11.b6f741fcc366abfad9c4.js} +3 -3
  5. udata/static/chunks/{11.55ab79044cda0271b595.js.map → 11.b6f741fcc366abfad9c4.js.map} +1 -1
  6. udata/static/chunks/{13.f29411b06be1883356a3.js → 13.2d06442dd9a05d9777b5.js} +2 -2
  7. udata/static/chunks/{13.f29411b06be1883356a3.js.map → 13.2d06442dd9a05d9777b5.js.map} +1 -1
  8. udata/static/chunks/{17.3bd0340930d4a314ce9c.js → 17.e8e4caaad5cb0cc0bacc.js} +2 -2
  9. udata/static/chunks/{17.3bd0340930d4a314ce9c.js.map → 17.e8e4caaad5cb0cc0bacc.js.map} +1 -1
  10. udata/static/chunks/{19.3e0e8651d948e04b8cf2.js → 19.f03a102365af4315f9db.js} +3 -3
  11. udata/static/chunks/{19.3e0e8651d948e04b8cf2.js.map → 19.f03a102365af4315f9db.js.map} +1 -1
  12. udata/static/chunks/{8.494b003a94383b142c18.js → 8.778091d55cd8ea39af6b.js} +2 -2
  13. udata/static/chunks/{8.494b003a94383b142c18.js.map → 8.778091d55cd8ea39af6b.js.map} +1 -1
  14. udata/static/chunks/{9.07515e5187f475bce828.js → 9.033d7e190ca9e226a5d0.js} +3 -3
  15. udata/static/chunks/{9.07515e5187f475bce828.js.map → 9.033d7e190ca9e226a5d0.js.map} +1 -1
  16. udata/static/common.js +1 -1
  17. udata/static/common.js.map +1 -1
  18. udata/tests/cli/test_db_cli.py +12 -0
  19. {udata-10.8.2.dev36980.dist-info → udata-10.8.2.dev37001.dist-info}/METADATA +2 -1
  20. {udata-10.8.2.dev36980.dist-info → udata-10.8.2.dev37001.dist-info}/RECORD +24 -24
  21. {udata-10.8.2.dev36980.dist-info → udata-10.8.2.dev37001.dist-info}/LICENSE +0 -0
  22. {udata-10.8.2.dev36980.dist-info → udata-10.8.2.dev37001.dist-info}/WHEEL +0 -0
  23. {udata-10.8.2.dev36980.dist-info → udata-10.8.2.dev37001.dist-info}/entry_points.txt +0 -0
  24. {udata-10.8.2.dev36980.dist-info → udata-10.8.2.dev37001.dist-info}/top_level.txt +0 -0
udata/commands/db.py CHANGED
@@ -2,6 +2,7 @@ import collections
2
2
  import copy
3
3
  import logging
4
4
  import os
5
+ import sys
5
6
  import traceback
6
7
  from itertools import groupby
7
8
  from typing import Optional
@@ -312,15 +313,26 @@ def check_references(models_to_check):
312
313
  f"\t{model.__name__}#{obj.id} have a broken reference for `{reference['name']}`"
313
314
  )
314
315
  elif reference["type"] == "list":
315
- attr_list = getattr(obj, reference["name"], [])
316
- for i, sub in enumerate(attr_list):
317
- # If it's still an instance of DBRef it means that it failed to
318
- # dereference the ID.
319
- if isinstance(sub, DBRef):
320
- errors[model][key] += 1
321
- print_and_save(
322
- f"\t{model.__name__}#{obj.id} have a broken reference for {reference['name']}[{i}]"
323
- )
316
+ field_exists = (
317
+ f"{reference['name']}__exists" # Eg: "contact_points__exists"
318
+ )
319
+ if model.objects(id=obj.id, **{field_exists: True}).count() == 0:
320
+ # See https://github.com/MongoEngine/mongoengine/issues/267#issuecomment-283065318
321
+ # Setting it explicitely to an empty list actually removes the field, it shouldn't.
322
+ errors[model][key] += 1
323
+ print_and_save(
324
+ f"\t{model.__name__}#{obj.id} have a non existing field `{reference['name']}`, instead of an empty list"
325
+ )
326
+ else:
327
+ attr_list = getattr(obj, reference["name"])
328
+ for i, sub in enumerate(attr_list):
329
+ # If it's still an instance of DBRef it means that it failed to
330
+ # dereference the ID.
331
+ if isinstance(sub, DBRef):
332
+ errors[model][key] += 1
333
+ print_and_save(
334
+ f"\t{model.__name__}#{obj.id} have a broken reference for {reference['name']}[{i}]"
335
+ )
324
336
  elif reference["type"] == "embed_list":
325
337
  p1, p2 = reference["name"].split("__")
326
338
  attr_list = getattr(obj, p1, [])
@@ -380,6 +392,7 @@ def check_references(models_to_check):
380
392
  sentry_sdk.capture_message(f"{total} integrity errors", "fatal")
381
393
  except ImportError:
382
394
  print("`sentry_sdk` not installed. The errors weren't reported")
395
+ sys.exit(1)
383
396
 
384
397
 
385
398
  @grp.command()