fix: May cause exception when deepcopy queryset(CookieJar)

This commit is contained in:
sswest 2022-06-01 13:30:07 +08:00
parent b62c08747f
commit 5ecb3e75eb
3 changed files with 17 additions and 2 deletions

View File

@ -20,7 +20,7 @@ dependencies = [
"iso8601 >= 0.1.12", "iso8601 >= 0.1.12",
"setuptools" "setuptools"
] ]
version = "0.0.4" version = "0.0.5"
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["src"] where = ["src"]

View File

@ -109,7 +109,7 @@ class Database(object):
self.db_url = db_url self.db_url = db_url
self.readonly = False self.readonly = False
self.timeout = timeout self.timeout = timeout
self.request_session = httpx.Client(verify=verify_ssl_cert) self.request_session = httpx.Client(verify=verify_ssl_cert, timeout=timeout)
if username: if username:
self.request_session.auth = (username, password or '') self.request_session.auth = (username, password or '')
self.log_statements = log_statements self.log_statements = log_statements

View File

@ -328,6 +328,21 @@ class QuerySet(object):
self._distinct = False self._distinct = False
self._final = False self._final = False
def __deepcopy__(self, memodict={}):
obj = type(self)(self._model_cls, self._database)
obj._order_by = deepcopy(self._order_by)
obj._where_q = deepcopy(self._where_q)
obj._prewhere_q = deepcopy(self._prewhere_q)
obj._grouping_fields = deepcopy(self._grouping_fields)
obj._grouping_with_totals = deepcopy(self._grouping_with_totals)
obj._fields = deepcopy(self._fields)
obj._limits = deepcopy(self._limits)
obj._limit_by = deepcopy(self._limit_by)
obj._limit_by_fields = deepcopy(self._limit_by_fields)
obj._distinct = deepcopy(self._distinct)
obj._final = deepcopy(self._final)
return obj
def __iter__(self): def __iter__(self):
""" """
Iterates over the model instances matching this queryset Iterates over the model instances matching this queryset