mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-07-27 00:09:49 +03:00
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:
parent
4d2ebd65fb
commit
1889ac6372
|
@ -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 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),\
|
assert partition_key is None or type(partition_key) in (list, tuple),\
|
||||||
'partition_key must be tuple or list if present'
|
'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'
|
'both replica_table_path and replica_name must be specified'
|
||||||
|
|
||||||
# These values conflict with each other (old and new syntax of table engines.
|
# These values conflict with each other (old and new syntax of table engines.
|
||||||
|
|
|
@ -3,7 +3,6 @@ from six import string_types, text_type, binary_type, integer_types
|
||||||
import datetime
|
import datetime
|
||||||
import iso8601
|
import iso8601
|
||||||
import pytz
|
import pytz
|
||||||
import time
|
|
||||||
from calendar import timegm
|
from calendar import timegm
|
||||||
from decimal import Decimal, localcontext
|
from decimal import Decimal, localcontext
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
@ -23,8 +22,8 @@ class Field(object):
|
||||||
assert (None, None) in {(default, alias), (alias, materialized), (default, materialized)}, \
|
assert (None, None) in {(default, alias), (alias, materialized), (default, materialized)}, \
|
||||||
"Only one of default, alias and materialized parameters can be given"
|
"Only one of default, alias and materialized parameters can be given"
|
||||||
assert alias is None or isinstance(alias, string_types) and alias != "",\
|
assert alias is None or isinstance(alias, string_types) and alias != "",\
|
||||||
"Alias field must be string field name, if given"
|
"Alias field must be a string, if given"
|
||||||
assert materialized is None or isinstance(materialized, string_types) and alias != "",\
|
assert materialized is None or isinstance(materialized, string_types) and materialized != "",\
|
||||||
"Materialized field must be string, if given"
|
"Materialized field must be string, if given"
|
||||||
assert readonly is None or type(readonly) is bool, "readonly parameter must be bool 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 != "", \
|
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.
|
this method returns a matching enum field.
|
||||||
'''
|
'''
|
||||||
import re
|
import re
|
||||||
try:
|
from enum import Enum
|
||||||
Enum # exists in Python 3.4+
|
|
||||||
except NameError:
|
|
||||||
from enum import Enum # use the enum34 library instead
|
|
||||||
members = {}
|
members = {}
|
||||||
for match in re.finditer("'(\w+)' = (\d+)", db_type):
|
for match in re.finditer("'(\w+)' = (\d+)", db_type):
|
||||||
members[match.group(1)] = int(match.group(2))
|
members[match.group(1)] = int(match.group(2))
|
||||||
|
|
|
@ -6,10 +6,7 @@ from infi.clickhouse_orm.models import Model
|
||||||
from infi.clickhouse_orm.fields import *
|
from infi.clickhouse_orm.fields import *
|
||||||
from infi.clickhouse_orm.engines import *
|
from infi.clickhouse_orm.engines import *
|
||||||
|
|
||||||
try:
|
from enum import Enum
|
||||||
Enum # exists in Python 3.4+
|
|
||||||
except NameError:
|
|
||||||
from enum import Enum # use the enum34 library instead
|
|
||||||
|
|
||||||
|
|
||||||
class EnumFieldsTest(unittest.TestCase):
|
class EnumFieldsTest(unittest.TestCase):
|
||||||
|
|
|
@ -7,14 +7,11 @@ from infi.clickhouse_orm.fields import *
|
||||||
from infi.clickhouse_orm.engines import *
|
from infi.clickhouse_orm.engines import *
|
||||||
from infi.clickhouse_orm.migrations import MigrationHistory
|
from infi.clickhouse_orm.migrations import MigrationHistory
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
# Add tests to path so that migrations will be importable
|
# Add tests to path so that migrations will be importable
|
||||||
import sys, os
|
import sys, os
|
||||||
sys.path.append(os.path.dirname(__file__))
|
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
|
import logging
|
||||||
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
|
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
|
||||||
|
|
|
@ -7,11 +7,7 @@ from infi.clickhouse_orm.query import Q
|
||||||
from .base_test_with_data import *
|
from .base_test_with_data import *
|
||||||
import logging
|
import logging
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
from enum import Enum
|
||||||
try:
|
|
||||||
Enum # exists in Python 3.4+
|
|
||||||
except NameError:
|
|
||||||
from enum import Enum # use the enum34 library instead
|
|
||||||
|
|
||||||
|
|
||||||
class QuerySetTestCase(TestCaseWithData):
|
class QuerySetTestCase(TestCaseWithData):
|
||||||
|
@ -227,7 +223,7 @@ class QuerySetTestCase(TestCaseWithData):
|
||||||
qs = Person.objects_in(self.database).order_by('first_name', 'last_name')
|
qs = Person.objects_in(self.database).order_by('first_name', 'last_name')
|
||||||
# Try different page sizes
|
# Try different page sizes
|
||||||
for page_size in (1, 2, 7, 10, 30, 100, 150):
|
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
|
page_num = 1
|
||||||
instances = set()
|
instances = set()
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user