Skip to content

Commit b989a41

Browse files
committed
fix regression failures
1 parent 6782feb commit b989a41

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/gino/crud.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ def __init__(self, **values):
435435

436436
@classmethod
437437
def _init_table(cls, sub_cls):
438-
rv = Model._init_table(sub_cls)
439438
for each_cls in sub_cls.__mro__[::-1]:
440439
for k, v in each_cls.__dict__.items():
441440
if isinstance(v, json_support.JSONProperty):
@@ -444,6 +443,7 @@ def _init_table(cls, sub_cls):
444443
'Requires "{}" JSON[B] column.'.format(v.prop_name)
445444
)
446445
v.name = k
446+
rv = Model._init_table(sub_cls)
447447
if rv is not None:
448448
rv.__model__ = weakref.ref(sub_cls)
449449
return rv
@@ -813,7 +813,8 @@ async def _query_and_update(bind, item, query, cols, execution_opts):
813813
else:
814814
conn = bind
815815
try:
816-
lastrowid, affected_rows = await conn.all(query)
816+
lastrowid, affected_rows = await conn.all(
817+
query.execution_options(return_affected_rows=True))
817818
if not lastrowid and not affected_rows:
818819
raise NoSuchRowError()
819820
# It's insertion and primary key is AUTO_INCREMENT

src/gino/dialects/base.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ async def execute(self, one=False, return_model=True, status=False):
217217
)
218218
if (not self.context.dialect.support_returning and
219219
(self.context.isinsert or self.context.isupdate)):
220-
# TODO: a better way to return execution status
221-
return context.get_lastrowid(), context.get_affected_rows()
220+
if self.context.execution_options.get(
221+
'return_affected_rows', False
222+
):
223+
return context.get_lastrowid(), context.get_affected_rows()
224+
return context.get_lastrowid()
222225
item = context.process_rows(rows, return_model=return_model)
223226
if one:
224227
if item:
@@ -284,9 +287,9 @@ def timeout(self):
284287
def loader(self):
285288
return self._compiled_first_opt("loader", None)
286289

287-
# @util.memoized_property
288-
# def return_lastrowid(self):
289-
# return self._compiled_first_opt("return_lastrowid", False)
290+
@util.memoized_property
291+
def return_affected_rows(self):
292+
return self._compiled_first_opt("return_affected_rows", False)
290293

291294
def process_rows(self, rows, return_model=True):
292295
if not rows:

0 commit comments

Comments
 (0)