Minor fixes

This commit is contained in:
Itai Shirav 2020-02-07 15:30:15 +02:00
parent c23947c28f
commit 0a94ac98a3
4 changed files with 7 additions and 7 deletions

View File

@ -87,10 +87,12 @@ class ModelBase(type):
if db_type.startswith('FixedString'):
length = int(db_type[12 : -1])
return orm_fields.FixedStringField(length)
# Decimal
# Decimal / Decimal32 / Decimal64 / Decimal128
if db_type.startswith('Decimal'):
precision, scale = [int(n.strip()) for n in db_type[8 : -1].split(',')]
return orm_fields.DecimalField(precision, scale)
p = db_type.index('(')
args = [int(n.strip()) for n in db_type[p + 1 : -1].split(',')]
field_class = getattr(orm_fields, db_type[:p] + 'Field')
return field_class(*args)
# Nullable
if db_type.startswith('Nullable'):
inner_field = cls.create_ad_hoc_field(db_type[9 : -1])

View File

@ -351,7 +351,7 @@ class QuerySet(object):
- `offset_limit`: either an integer specifying the limit, or a tuple of integers (offset, limit).
- `fields`: the field names to use in the clause.
"""
if isinstance(offset_limit, six.integer_types):
if isinstance(offset_limit, int):
# Single limit
offset_limit = (0, offset_limit)
offset = offset_limit[0]

View File

@ -215,6 +215,4 @@ class DatabaseTestCase(TestCaseWithData):
from infi.clickhouse_orm.models import ModelBase
query = "SELECT DISTINCT type FROM system.columns"
for row in self.database.select(query):
if row.type in ('IPv4', 'IPv6'):
continue # unsupported yet
ModelBase.create_ad_hoc_field(row.type)

View File

@ -307,7 +307,7 @@ class FuncsTestCase(TestCaseWithData):
try:
self._test_func(F.base64Decode(F.base64Encode('Hello')), 'Hello')
self._test_func(F.tryBase64Decode(F.base64Encode('Hello')), 'Hello')
self._test_func(F.tryBase64Decode('zzz'), None)
self._test_func(F.tryBase64Decode(':-)'), None)
except ServerError as e:
# ClickHouse version that doesn't support these functions
raise unittest.SkipTest(e.message)