Skip to content

Commit 80a8ccf

Browse files
committed
Fix docs and remove useless internal param
1 parent 65141cb commit 80a8ccf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

gino/crud.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ class UpdateRequest:
7878
specific model instance and its database row.
7979
8080
"""
81-
def __init__(self, instance, lookup=True):
81+
def __init__(self, instance):
8282
self._instance = instance
8383
self._values = {}
8484
self._props = {}
8585
self._literal = True
8686
self._locator = None
87-
if lookup and instance.__table__ is not None:
87+
if instance.__table__ is not None:
8888
try:
8989
self._locator = instance.lookup()
9090
except LookupError:
@@ -413,7 +413,7 @@ class CRUDModel(Model):
413413
def __init__(self, **values):
414414
super().__init__()
415415
self.__profile__ = None
416-
self._update_request_cls(self, False).update(**values)
416+
self._update_request_cls(self).update(**values)
417417

418418
@classmethod
419419
def _init_table(cls, sub_cls):
@@ -532,7 +532,7 @@ def append_where_primary_key(self, q):
532532
await user.query.gino.first()
533533
534534
.. deprecated:: 0.7.6
535-
Use :meth:`lookup` instead.
535+
Use :meth:`.lookup` instead.
536536
537537
"""
538538
return q.where(self.lookup()) # pragma: no cover
@@ -542,8 +542,11 @@ def lookup(self):
542542
Generate where-clause expression to locate this model instance.
543543
544544
By default this method uses current values of all primary keys, and you
545-
can override it to behave differently. All instance-level CRUD
546-
operations depend on this method internally.
545+
can override it to behave differently. Most instance-level CRUD
546+
operations depend on this method internally. Particularly while
547+
:meth:`.lookup` is called in :meth:`.update`, the where condition is
548+
used in :meth:`.UpdateRequest.apply`, so that queries like ``UPDATE ...
549+
SET id = NEW WHERE id = OLD`` could work correctly.
547550
548551
:return:
549552

0 commit comments

Comments
 (0)