Commit 6560ea5
Capture RETURNING rows in AsyncAdaptedCursor.executemany
AsyncAdaptedCursor.execute() mirrors the underlying cursor's
description and fetchall() into self.description / self._rows when
the statement produces a result set. executemany() cleared state
up front but never re-read description or rows after the underlying
call — it captured only lastrowid and rowcount. With
insert_returning and use_insertmanyvalues pinned True in the
dialect, async SQLAlchemy users doing
``insert(T).values([...]).returning(T.id)`` silently got empty
results: the dbapi cursor accumulated the returned rows (see
AsyncCursor.executemany's _ExecuteManyAccumulator) but the adapter
dropped them.
Mirror execute()'s post-call pattern: if cursor.description is
truthy after executemany, set description and drain fetchall() into
self._rows via deque; otherwise fall through to the existing
lastrowid/rowcount capture. The up-front state reset stays.
Tests: unit test verifies description=None DML path still captures
lastrowid/rowcount; new test verifies description-populated
RETURNING path captures rows in order and exposes description.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8f3ec92 commit 6560ea5
2 files changed
Lines changed: 54 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
88 | 98 | | |
89 | 99 | | |
90 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
73 | | - | |
74 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
75 | 114 | | |
76 | 115 | | |
77 | 116 | | |
| |||
0 commit comments