@@ -178,6 +178,37 @@ async def test_results_support_mapping_interface(database_url):
178
178
assert results_as_dicts [0 ]["completed" ] == True
179
179
180
180
181
+ @pytest .mark .parametrize ("database_url" , DATABASE_URLS )
182
+ @async_adapter
183
+ async def test_results_support_column_reference (database_url ):
184
+ """
185
+ Casting results to a dict should work, since the interface defines them
186
+ as supporting the mapping interface.
187
+ """
188
+ async with Database (database_url ) as database :
189
+ async with database .transaction (force_rollback = True ):
190
+ now = datetime .datetime .now ().replace (microsecond = 0 )
191
+ today = datetime .date .today ()
192
+
193
+ # execute()
194
+ query = articles .insert ()
195
+ values = {"title" : "Hello, world Article" , "published" : now }
196
+ await database .execute (query , values )
197
+
198
+ query = custom_date .insert ()
199
+ values = {"title" : "Hello, world Custom" , "published" : today }
200
+ await database .execute (query , values )
201
+
202
+ # fetch_all()
203
+ query = sqlalchemy .select ([articles , custom_date ])
204
+ results = await database .fetch_all (query = query )
205
+ assert len (results ) == 1
206
+ assert results [0 ][articles .c .title ] == "Hello, world Article"
207
+ assert results [0 ][articles .c .published ] == now
208
+ assert results [0 ][custom_date .c .title ] == "Hello, world Custom"
209
+ assert results [0 ][custom_date .c .published ] == today
210
+
211
+
181
212
@pytest .mark .parametrize ("database_url" , DATABASE_URLS )
182
213
@async_adapter
183
214
async def test_fetch_one_returning_no_results (database_url ):
0 commit comments