Skip to content

Commit

Permalink
feat: error out for QA on multivalue questions
Browse files Browse the repository at this point in the history
  • Loading branch information
dodumosu committed May 21, 2020
1 parent 6c5210c commit a406db2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apollo/submissions/qa/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ def visit_variable(self, node, children):
if var_name not in self.form.tags:
raise ValueError('Variable ({}) not in form'.format(var_name))

field = self.form.get_field_by_tag(var_name)
if field['type'] == 'multiselect':
raise ValueError('QA not supported for multi-value fields')

return self.submission.data.get(var_name, 'NULL')

def visit_lookup(self, node, children):
Expand Down Expand Up @@ -227,10 +231,13 @@ def visit_variable(self, node, children):
if var_name not in self.form.tags:
raise ValueError('Variable ({}) not in form'.format(var_name))

field = self.form.get_field_by_tag(var_name)
if field['type'] == 'multiselect':
raise ValueError('QA not supported for multi-value fields')

# casting is necessary because PostgreSQL will throw
# a fit if you attempt some operations that mix JSONB
# with other types
field = self.form.get_field_by_tag(var_name)
cast_type = FIELD_TYPE_CASTS.get(field['type'])

# there are side effects when attempting to make comparisons
Expand Down

0 comments on commit a406db2

Please sign in to comment.