Minor bug fixes

field creation won't allow empty string materialized field.
repliaca_name check is none
fix enum usage
typos fix
This commit is contained in:
Roy Belio 2019-06-23 11:53:58 +03:00
parent 4d2ebd65fb
commit 1889ac6372
5 changed files with 8 additions and 22 deletions

View File

@ -40,7 +40,7 @@ class MergeTree(Engine):
assert date_col is None or isinstance(date_col, six.string_types), 'date_col must be string if present'
assert partition_key is None or type(partition_key) in (list, tuple),\
'partition_key must be tuple or list if present'
assert (replica_table_path is None) == (replica_name == None), \
assert (replica_table_path is None) == (replica_name is None), \
'both replica_table_path and replica_name must be specified'
# These values conflict with each other (old and new syntax of table engines.

View File

@ -3,7 +3,6 @@ from six import string_types, text_type, binary_type, integer_types
import datetime
import iso8601
import pytz
import time
from calendar import timegm
from decimal import Decimal, localcontext
from uuid import UUID
@ -23,8 +22,8 @@ class Field(object):
assert (None, None) in {(default, alias), (alias, materialized), (default, materialized)}, \
"Only one of default, alias and materialized parameters can be given"
assert alias is None or isinstance(alias, string_types) and alias != "",\
"Alias field must be string field name, if given"
assert materialized is None or isinstance(materialized, string_types) and alias != "",\
"Alias field must be a string, if given"
assert materialized is None or isinstance(materialized, string_types) and materialized != "",\
"Materialized field must be string, if given"
assert readonly is None or type(readonly) is bool, "readonly parameter must be bool if given"
assert codec is None or isinstance(codec, string_types) and codec != "", \
@ -407,10 +406,7 @@ class BaseEnumField(Field):
this method returns a matching enum field.
'''
import re
try:
Enum # exists in Python 3.4+
except NameError:
from enum import Enum # use the enum34 library instead
from enum import Enum
members = {}
for match in re.finditer("'(\w+)' = (\d+)", db_type):
members[match.group(1)] = int(match.group(2))

View File

@ -6,10 +6,7 @@ from infi.clickhouse_orm.models import Model
from infi.clickhouse_orm.fields import *
from infi.clickhouse_orm.engines import *
try:
Enum # exists in Python 3.4+
except NameError:
from enum import Enum # use the enum34 library instead
from enum import Enum
class EnumFieldsTest(unittest.TestCase):

View File

@ -7,14 +7,11 @@ from infi.clickhouse_orm.fields import *
from infi.clickhouse_orm.engines import *
from infi.clickhouse_orm.migrations import MigrationHistory
from enum import Enum
# Add tests to path so that migrations will be importable
import sys, os
sys.path.append(os.path.dirname(__file__))
try:
Enum # exists in Python 3.4+
except NameError:
from enum import Enum # use the enum34 library instead
import logging
logging.basicConfig(level=logging.DEBUG, format='%(message)s')

View File

@ -7,11 +7,7 @@ from infi.clickhouse_orm.query import Q
from .base_test_with_data import *
import logging
from datetime import date, datetime
try:
Enum # exists in Python 3.4+
except NameError:
from enum import Enum # use the enum34 library instead
from enum import Enum
class QuerySetTestCase(TestCaseWithData):
@ -227,7 +223,7 @@ class QuerySetTestCase(TestCaseWithData):
qs = Person.objects_in(self.database).order_by('first_name', 'last_name')
# Try different page sizes
for page_size in (1, 2, 7, 10, 30, 100, 150):
# Iterate over pages and collect all intances
# Iterate over pages and collect all instances
page_num = 1
instances = set()
while True: