Project

General

Profile

0001-feeder-prepend-field_-to-column-name-for-string-and-.patch

Benjamin Dauvergne, 07 Feb 2019 11:35 PM

Download (4.98 KB)

View differences:

Subject: [PATCH] feeder: prepend field_ to column name for string and bool
 fields (fixes #30475)

 tests/conftest.py  |  6 +++---
 tests/olap.model   | 18 +++++++++---------
 tests/test_wcs.py  | 10 +++++-----
 wcs_olap/feeder.py |  6 +++---
 4 files changed, 20 insertions(+), 20 deletions(-)
tests/conftest.py
88 88
formdef.name = 'Demande'
89 89
formdef.category_id = cat.id
90 90
formdef.fields = [
91
    fields.StringField(id='1', label='1st field', type='string', anonymise=False, varname='field_string'),
91
    fields.StringField(id='1', label='1st field', type='string', anonymise=False, varname='string'),
92 92
    fields.ItemField(id='2', label='2nd field', type='item',
93
                     items=['foo', 'bar', 'baz'], varname='field_item'),
94
    fields.BoolField(id='3', label='3rd field', type='bool', varname='field_bool'),
93
                     items=['foo', 'bar', 'baz'], varname='item'),
94
    fields.BoolField(id='3', label='3rd field', type='bool', varname='bool'),
95 95
]
96 96
formdef.store()
97 97

  
tests/olap.model
242 242
            {
243 243
               "filter": true,
244 244
               "label": "1st field",
245
               "name": "field_string",
245
               "name": "string",
246 246
               "type": "string",
247 247
               "value": "\"field_string\""
248 248
            },
249 249
            {
250 250
               "filter" : true,
251 251
               "join" : [
252
                  "field_item"
252
                  "item"
253 253
               ],
254 254
               "label" : "2nd field",
255
               "name" : "field_item",
255
               "name" : "item",
256 256
               "type" : "integer",
257
               "value" : "\"field_item\".id",
258
               "value_label" : "\"field_item\".label"
257
               "value" : "\"item\".id",
258
               "value_label" : "\"item\".label"
259 259
            },
260 260
            {
261 261
             "filter": true,
262 262
             "label": "3rd field",
263
             "name": "field_bool",
263
             "name": "bool",
264 264
             "type": "bool",
265 265
             "value": "\"field_bool\"",
266 266
             "value_label": "(case when \"field_bool\" IS NOT NULL then 'Oui' else 'Non' end)"
......
326 326
            },
327 327
            {
328 328
               "detail" : "id",
329
               "master" : "field_field_item",
330
               "name" : "field_item",
331
               "table" : "formdata_demande_field_field_item"
329
               "master" : "field_item",
330
               "name" : "item",
331
               "table" : "formdata_demande_field_item"
332 332
            }
333 333
         ],
334 334
         "key" : "id",
tests/test_wcs.py
52 52
        ('formdata_demande', 'geolocation_base'),
53 53
        ('formdata_demande', 'json_data'),
54 54
        ('formdata_demande', 'status_id'),
55
        ('formdata_demande', 'field_field_string'),
56
        ('formdata_demande', 'field_field_item'),
57
        ('formdata_demande', 'field_field_bool'),
55
        ('formdata_demande', 'field_string'),
56
        ('formdata_demande', 'field_item'),
57
        ('formdata_demande', 'field_bool'),
58 58
        ('formdata_demande', 'function__receiver'),
59
        ('formdata_demande_field_field_item', 'id'),
60
        ('formdata_demande_field_field_item', 'label'),
59
        ('formdata_demande_field_item', 'id'),
60
        ('formdata_demande_field_item', 'label'),
61 61
        ('formdef', 'id'),
62 62
        ('formdef', 'category_id'),
63 63
        ('formdef', 'label'),
wcs_olap/feeder.py
901 901
                    'name': field.varname,
902 902
                    'label': field.label.lower(),
903 903
                    'type': 'bool',
904
                    'value': '"%s"' % field.varname,
905
                    'value_label': '(case when "%s" IS NOT NULL then \'Oui\' else \'Non\' end)' % field.varname,
904
                    'value': '"field_%s"' % field.varname,
905
                    'value_label': '(case when "field_%s" IS NOT NULL then \'Oui\' else \'Non\' end)' % field.varname,
906 906
                    'filter': True,
907 907
                }
908 908
            elif field.type == 'string':
......
910 910
                    'name': field.varname,
911 911
                    'label': field.label.lower(),
912 912
                    'type': 'string',
913
                    'value': '"%s"' % field.varname,
913
                    'value': '"field_%s"' % field.varname,
914 914
                    'filter': True,
915 915
                }
916 916
            else:
917
-