Add grid filter type for BigInteger columns
so we can filter by larger values
This commit is contained in:
parent
5ab47aeead
commit
de373a683b
|
@ -689,6 +689,8 @@ class Grid(object):
|
|||
factory = gridfilters.AlchemyStringFilter
|
||||
elif isinstance(column.type, sa.Numeric):
|
||||
factory = gridfilters.AlchemyNumericFilter
|
||||
elif isinstance(column.type, sa.BigInteger):
|
||||
factory = gridfilters.AlchemyBigIntegerFilter
|
||||
elif isinstance(column.type, sa.Integer):
|
||||
factory = gridfilters.AlchemyIntegerFilter
|
||||
elif isinstance(column.type, sa.Boolean):
|
||||
|
|
|
@ -659,6 +659,7 @@ class AlchemyIntegerFilter(AlchemyNumericFilter):
|
|||
"""
|
||||
Integer filter for SQLAlchemy.
|
||||
"""
|
||||
bigint = False
|
||||
|
||||
def value_invalid(self, value):
|
||||
if value:
|
||||
|
@ -666,9 +667,10 @@ class AlchemyIntegerFilter(AlchemyNumericFilter):
|
|||
return True
|
||||
if not value.isdigit():
|
||||
return True
|
||||
# TODO: this one is to avoid DataError from PG, but perhaps that
|
||||
# isn't a good enough reason to make this global logic?
|
||||
if int(value) > 2147483647:
|
||||
# normal Integer columns have a max value, beyond which PG
|
||||
# will throw an error if we try to query for larger values
|
||||
# TODO: this seems hacky, how to better handle it?
|
||||
if not self.bigint and int(value) > 2147483647:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -678,6 +680,13 @@ class AlchemyIntegerFilter(AlchemyNumericFilter):
|
|||
return int(value)
|
||||
|
||||
|
||||
class AlchemyBigIntegerFilter(AlchemyIntegerFilter):
|
||||
"""
|
||||
BigInteger filter for SQLAlchemy.
|
||||
"""
|
||||
bigint = True
|
||||
|
||||
|
||||
class AlchemyBooleanFilter(AlchemyGridFilter):
|
||||
"""
|
||||
Boolean filter for SQLAlchemy.
|
||||
|
|
Loading…
Reference in a new issue