mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-25 18:43:46 +03:00
Fixed some bugs
This commit is contained in:
parent
e81a6b5e4a
commit
0e4dd6b69f
|
@ -119,6 +119,9 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
|
||||||
:param operations: A list of operations to perform
|
:param operations: A list of operations to perform
|
||||||
:return: A list of django_model instances
|
:return: A list of django_model instances
|
||||||
"""
|
"""
|
||||||
|
if not operations:
|
||||||
|
return []
|
||||||
|
|
||||||
pk_by_db = defaultdict(set)
|
pk_by_db = defaultdict(set)
|
||||||
for op, pk_str in operations:
|
for op, pk_str in operations:
|
||||||
using, pk = pk_str.split('.')
|
using, pk = pk_str.split('.')
|
||||||
|
@ -168,6 +171,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
|
||||||
with statsd.timer(statsd_key.format('get_operations')):
|
with statsd.timer(statsd_key.format('get_operations')):
|
||||||
operations = storage.get_operations(import_key, cls.get_sync_batch_size())
|
operations = storage.get_operations(import_key, cls.get_sync_batch_size())
|
||||||
|
|
||||||
|
if operations:
|
||||||
with statsd.timer(statsd_key.format('get_sync_objects')):
|
with statsd.timer(statsd_key.format('get_sync_objects')):
|
||||||
import_objects = cls.get_sync_objects(operations)
|
import_objects = cls.get_sync_objects(operations)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,12 @@ class Django2ClickHouseModelSerializer:
|
||||||
self.exclude_serialize_fields = exclude_fields
|
self.exclude_serialize_fields = exclude_fields
|
||||||
|
|
||||||
def serialize(self, obj): # type: (DjangoModel) -> 'ClickHouseModel'
|
def serialize(self, obj): # type: (DjangoModel) -> 'ClickHouseModel'
|
||||||
data = model_to_dict(obj, self.serialize_fields, self.exclude_serialize_fields)
|
# Standard model_to_dict ignores some fields if they have invalid naming
|
||||||
|
data = {}
|
||||||
|
for name in set(self.serialize_fields) - set(self.exclude_serialize_fields):
|
||||||
|
val = getattr(obj, name, None)
|
||||||
|
if val is not None:
|
||||||
|
data[name] = val
|
||||||
|
|
||||||
# Remove None values, they should be initialized as defaults
|
# Remove None values, they should be initialized as defaults
|
||||||
params = {}
|
params = {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user