feeder: fix value_label SQL for boolean fields (fixes #30477)

This commit is contained in:
Benjamin Dauvergne 2019-02-07 23:37:24 +01:00
parent 63dc0183a3
commit a2f21e02e0
2 changed files with 6 additions and 2 deletions

View File

@ -263,7 +263,7 @@
"name": "bool",
"type": "bool",
"value": "\"field_bool\"",
"value_label": "(case when \"field_bool\" IS NOT NULL then 'Oui' else 'Non' end)"
"value_label": "(CASE WHEN \"field_bool\" IS NULL THEN NULL WHEN \"field_bool\" THEN 'Oui' ELSE 'Non' END)"
}
],
"fact_table" : "formdata_demande",

View File

@ -902,7 +902,11 @@ class WcsFormdefFeeder(object):
'label': field.label.lower(),
'type': 'bool',
'value': '"field_%s"' % field.varname,
'value_label': '(case when "field_%s" IS NOT NULL then \'Oui\' else \'Non\' end)' % field.varname,
'value_label': '(CASE WHEN "field_%(varname)s" IS NULL THEN NULL'
' WHEN "field_%(varname)s" THEN \'Oui\''
' ELSE \'Non\' END)' % {
'varname': field.varname,
},
'filter': True,
}
elif field.type == 'string':