mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-10 19:36:33 +03:00
Include alias and materialized fields in queryset results
This commit is contained in:
parent
238fd11d6b
commit
32c77ab190
|
@ -1,6 +1,10 @@
|
|||
Change Log
|
||||
==========
|
||||
|
||||
Unreleased
|
||||
----------
|
||||
- Include alias and materialized fields in queryset results
|
||||
|
||||
v1.0.1
|
||||
------
|
||||
- NullableField: take extra_null_values into account in `validate` and `to_python`
|
||||
|
|
|
@ -237,7 +237,7 @@ class QuerySet(object):
|
|||
self._database = database
|
||||
self._order_by = []
|
||||
self._q = []
|
||||
self._fields = []
|
||||
self._fields = model_cls.fields().keys()
|
||||
self._limits = None
|
||||
self._distinct = False
|
||||
|
||||
|
|
|
@ -220,6 +220,18 @@ class QuerySetTestCase(TestCaseWithData):
|
|||
self._test_qs(qs, 100)
|
||||
self._test_qs(qs.only('first_name'), 94)
|
||||
|
||||
def test_materialized_field(self):
|
||||
self._insert_sample_model()
|
||||
qs = SampleModel.objects_in(self.database)
|
||||
for obj in qs:
|
||||
self.assertTrue(obj.materialized_date != DateField.min_value)
|
||||
|
||||
def test_alias_field(self):
|
||||
self._insert_sample_model()
|
||||
qs = SampleModel.objects_in(self.database)
|
||||
for obj in qs:
|
||||
self.assertTrue(obj.num_squared == obj.num ** 2)
|
||||
|
||||
|
||||
class AggregateTestCase(TestCaseWithData):
|
||||
|
||||
|
@ -358,6 +370,7 @@ class SampleModel(Model):
|
|||
materialized_date = DateField(materialized='toDate(timestamp)')
|
||||
num = Int32Field()
|
||||
color = Enum8Field(Color)
|
||||
num_squared = Int32Field(alias='num*num')
|
||||
|
||||
engine = MergeTree('materialized_date', ('materialized_date',))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user