Projet

Général

Profil

0001-misc-don-t-look-for-cards-with-an-id-over-postgresql.patch

Frédéric Péters, 18 octobre 2020 14:57

Télécharger (1,64 ko)

Voir les différences:

Subject: [PATCH] misc: don't look for cards with an id over postgresql limit
 (#47767)

 tests/test_carddef.py | 13 +++++++++++++
 wcs/carddef.py        |  4 ++++
 2 files changed, 17 insertions(+)
tests/test_carddef.py
108 108

  
109 109
    tmpl = Template('{{cards|objects:"foo"|filter_by:"foo"|filter_value:"blah"|count}}')
110 110
    assert tmpl.render(context) == '10'
111

  
112

  
113
def test_data_source_access_invalid_id(pub):
114
    CardDef.wipe()
115
    carddef = CardDef()
116
    carddef.name = 'foo'
117
    carddef.fields = [
118
        StringField(id='1', label='Test', type='string', varname='foo'),
119
    ]
120
    carddef.store()
121
    carddef.data_class().wipe()
122

  
123
    assert CardDef.get_data_source_items('carddef:foo', get_by_id='424508729041982') == []
wcs/carddef.py
193 193
        if query:
194 194
            criterias.append(ILike('digest', query))
195 195
        if get_by_id:
196
            if int(get_by_id) >= 2**31:
197
                # out of range for postgresql integer type; would raise
198
                # DataError.
199
                return []
196 200
            criterias.append(Equal('id', get_by_id))
197 201
        if get_by_text:
198 202
            criterias.append(Equal('digest', get_by_text))
199
-