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

remove additional auto-id field #188

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions commcare_export/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ def lookup(self, name):

def iter(jsonpath_expr=jsonpath_expr): # Capture closure
for datum in jsonpath_expr.find(self.__bindings):
# HACK: The auto id from jsonpath_rw is good, but we lose it when we do .value here,
# so just slap it on if not present
if isinstance(datum.value, dict) and 'id' not in datum.value:
datum.value['id'] = jsonpath.AutoIdForDatum(datum).value
yield datum
return RepeatableIterator(iter)

Expand Down
8 changes: 2 additions & 6 deletions tests/test_minilinq.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,11 @@ def test_eval_auto_id_reference_nested(self):
Reference("id"), Reference('baz'), Reference('$.id'), Reference('$.foo.id'), Reference('$.foo.name')
]))
self.check_case(mmap.eval(env), [
['1.bar.1.bar.[0]', 'a1', '1', '1.bid', 'bob'],
['1.bar.[0]', 'a1', '1', '1.bid', 'bob'],
['1.bar.bazzer', 'a2', '1', '1.bid', 'bob']
])

# Without the additional auto id field added in JsonPathEnv the result for Reference("id") changes
# as follows:
# '1.bar.1.bar.[0]' -> '1.bar.[0]'

# With the change above AND a change to jsonpath_rw to prevent converting IDs that exist into
# With a change to jsonpath_rw to prevent converting IDs that exist into
# auto IDs (see https://github.com/kennknowles/python-jsonpath-rw/pull/96) we get the following:
# Reference("id"):
# '1.bar.bazzer' -> 'bazzer'
Expand Down