mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 00:56:34 +03:00
Functions WIP
This commit is contained in:
parent
8a21e02862
commit
cc0f2c4e91
|
@ -1136,14 +1136,6 @@ class F(Cond, FunctionOperatorsMixin):
|
||||||
def unhex(x):
|
def unhex(x):
|
||||||
return F('unhex', x)
|
return F('unhex', x)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def UUIDNumToString(s):
|
|
||||||
return F('UUIDNumToString', s)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def UUIDStringToNum(s):
|
|
||||||
return F('UUIDStringToNum', s)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bitmaskToArray(x):
|
def bitmaskToArray(x):
|
||||||
return F('bitmaskToArray', x)
|
return F('bitmaskToArray', x)
|
||||||
|
@ -1152,7 +1144,23 @@ class F(Cond, FunctionOperatorsMixin):
|
||||||
def bitmaskToList(x):
|
def bitmaskToList(x):
|
||||||
return F('bitmaskToList', x)
|
return F('bitmaskToList', x)
|
||||||
|
|
||||||
|
# Functions for working with UUID
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def generateUUIDv4():
|
||||||
|
return F('generateUUIDv4')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def toUUID(s):
|
||||||
|
return F('toUUID', s)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def UUIDNumToString(s):
|
||||||
|
return F('UUIDNumToString', s)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def UUIDStringToNum(s):
|
||||||
|
return F('UUIDStringToNum', s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -440,9 +440,14 @@ class FuncsTestCase(TestCaseWithData):
|
||||||
self._test_func(F.randConstant(17))
|
self._test_func(F.randConstant(17))
|
||||||
|
|
||||||
def test_encoding_functions(self):
|
def test_encoding_functions(self):
|
||||||
uuid = '123e4567-e89b-12d3-a456-426655440000'
|
|
||||||
self._test_func(F.hex(F.unhex('0FA1')), '0FA1')
|
self._test_func(F.hex(F.unhex('0FA1')), '0FA1')
|
||||||
self._test_func(F.UUIDNumToString(F.UUIDStringToNum(uuid)), uuid)
|
|
||||||
self._test_func(F.bitmaskToArray(17))
|
self._test_func(F.bitmaskToArray(17))
|
||||||
self._test_func(F.bitmaskToList(18))
|
self._test_func(F.bitmaskToList(18))
|
||||||
|
|
||||||
|
def test_uuid_functions(self):
|
||||||
|
from uuid import UUID
|
||||||
|
uuid = self._test_func(F.generateUUIDv4())
|
||||||
|
self.assertEqual(type(uuid), UUID)
|
||||||
|
s = str(uuid)
|
||||||
|
self._test_func(F.toUUID(s), uuid)
|
||||||
|
self._test_func(F.UUIDNumToString(F.UUIDStringToNum(s)), s)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user