Commit 915dcd9
Pin cursor.description for empty and all-NULL result sets
Two edge cases of cursor.description were untested:
- Empty result set. A ``SELECT ... WHERE 1=0`` returns zero rows,
so the wire layer never populates ``column_types``. description
carries the column names but every type_code is None. Callers
(including SQLAlchemy's introspection path) depend on description
being truthy for any query that "could" return rows.
- Row of all NULLs. The wire protocol's per-row type header flips
every value's nibble to NULL when the value is None, and
column_types is sourced from the first row, so the declared SQL
schema type is lost. Every description[i][1] ends up as
ValueType.NULL (5).
Neither behaviour is a bug — both are load-bearing interpretations
of the wire format — but they weren't tested and a refactor could
silently alter them. Pin both contracts with integration tests
against the live cluster.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ed2820a commit 915dcd9
1 file changed
+53
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
0 commit comments