зеркало из https://github.com/Azure/pykusto.git
fix #22: query deep copy
This commit is contained in:
Родитель
3ef71e8514
Коммит
5e36e810f7
|
@ -1,5 +1,5 @@
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from copy import copy
|
from copy import copy, deepcopy
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
|
@ -54,8 +54,8 @@ class Query:
|
||||||
self._table = head if isinstance(head, Table) else None
|
self._table = head if isinstance(head, Table) else None
|
||||||
|
|
||||||
def __add__(self, other: 'Query'):
|
def __add__(self, other: 'Query'):
|
||||||
self_copy = self.deepcopy()
|
self_copy = deepcopy(self)
|
||||||
other_copy = other.deepcopy()
|
other_copy = deepcopy(other)
|
||||||
|
|
||||||
other_base = other_copy
|
other_base = other_copy
|
||||||
while other_base._head is not None:
|
while other_base._head is not None:
|
||||||
|
@ -65,10 +65,10 @@ class Query:
|
||||||
other_base._head = self_copy
|
other_base._head = self_copy
|
||||||
return other_copy
|
return other_copy
|
||||||
|
|
||||||
def deepcopy(self):
|
def __deepcopy__(self, memo):
|
||||||
new_object = copy(self)
|
new_object = copy(self)
|
||||||
if self._head is not None:
|
if self._head is not None:
|
||||||
new_object._head = self._head.deepcopy()
|
new_object._head = self._head.__deepcopy__(memo)
|
||||||
return new_object
|
return new_object
|
||||||
|
|
||||||
def where(self, predicate: BooleanType) -> 'WhereQuery':
|
def where(self, predicate: BooleanType) -> 'WhereQuery':
|
||||||
|
|
Загрузка…
Ссылка в новой задаче