Skip to content

Commit

Permalink
when creating a variable with create_variable() and passing subvariab…
Browse files Browse the repository at this point in the history
…les with id and alias, respect those in favor of default values generated by Crunch
  • Loading branch information
mathiasbc committed Sep 12, 2019
1 parent 705281a commit 2646fe1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scrunch/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,9 +1703,14 @@ def create_variable(self, var_type, name, alias=None, description='',
if categories:
payload['categories'] = categories
if subvariables:
payload['subreferences'] = [
{'name': item['name']} for item in subvariables
]
payload['subreferences'] = []
for item in subvariables:
subrefs = {'name': item['name']}
if item.get('alias'):
subrefs['alias'] = item['alias']
if item.get('id'):
subrefs['id'] = item['id']
payload['subreferences'].append(subrefs)
if values:
payload['values'] = values

Expand Down

0 comments on commit 2646fe1

Please sign in to comment.