Skip to content

Commit 50daf3d

Browse files
committed
add comment
1 parent e36553a commit 50daf3d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/gino/crud.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,12 @@ async def _query_and_update(bind, item, query, cols, execution_opts):
792792

793793
async def _execute_and_fetch(conn, query):
794794
context, row = await conn._first_with_context(query)
795+
# For DBMS like MySQL that doesn't support returning inserted or modified
796+
# rows, a workaround is applied to infer necessary data to query from the
797+
# database. This is not able to cover all cases, especially for those
798+
# statements that the end results are not exactly the same as in the queries.
799+
# One example is the DATETIME type in MySQL. By default, inserted date are
800+
# rounded to seconds. This is not visible to the engine.
795801
if not bind._dialect.support_returning:
796802
if context.isinsert:
797803
table = context.compiled.statement.table

src/gino/dialects/aiomysql.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,7 @@ async def _do_execute_many(self, conn, prefix, values, postfix, args):
192192
stmt += b","
193193
stmt += v
194194
await self._async_execute(conn, stmt + postfix, None, None)
195-
rows += self.affected_rows
196-
self.affected_rows = rows
197-
return None
195+
self.affected_rows += rows
198196

199197
@property
200198
def description(self):

0 commit comments

Comments
 (0)