misc: don't look for cards with an id over postgresql limit (#47767)
This commit is contained in:
parent
4dd7bc4aaa
commit
16a147d537
|
@ -108,3 +108,16 @@ def test_template_access(pub):
|
|||
|
||||
tmpl = Template('{{cards|objects:"foo"|filter_by:"foo"|filter_value:"blah"|count}}')
|
||||
assert tmpl.render(context) == '10'
|
||||
|
||||
|
||||
def test_data_source_access_invalid_id(pub):
|
||||
CardDef.wipe()
|
||||
carddef = CardDef()
|
||||
carddef.name = 'foo'
|
||||
carddef.fields = [
|
||||
StringField(id='1', label='Test', type='string', varname='foo'),
|
||||
]
|
||||
carddef.store()
|
||||
carddef.data_class().wipe()
|
||||
|
||||
assert CardDef.get_data_source_items('carddef:foo', get_by_id='424508729041982') == []
|
||||
|
|
|
@ -193,6 +193,10 @@ class CardDef(FormDef):
|
|||
if query:
|
||||
criterias.append(ILike('digest', query))
|
||||
if get_by_id:
|
||||
if int(get_by_id) >= 2**31:
|
||||
# out of range for postgresql integer type; would raise
|
||||
# DataError.
|
||||
return []
|
||||
criterias.append(Equal('id', get_by_id))
|
||||
if get_by_text:
|
||||
criterias.append(Equal('digest', get_by_text))
|
||||
|
|
Loading…
Reference in New Issue