@@ -285,3 +285,37 @@ class Game(db.Model):
285285 assert await Game .select ("channel_id" ).gino .all () == [("X" ,), ("Z" ,)]
286286 finally :
287287 await Game .gino .drop ()
288+
289+
290+ async def test_lookup_custom_name (bind ):
291+ from gino .exceptions import NoSuchRowError
292+
293+ class ModelWithCustomColumnNames (db .Model ):
294+ __tablename__ = 'gino_test_custom_column_names'
295+
296+ id = db .Column ('other' , db .Integer (), primary_key = True )
297+ field = db .Column (db .Text ())
298+
299+ await ModelWithCustomColumnNames .gino .create ()
300+
301+ try :
302+ # create
303+ m1 = await ModelWithCustomColumnNames .create (id = 1 , field = 'A' )
304+ m2 = await ModelWithCustomColumnNames .create (id = 2 , field = 'B' )
305+
306+ # update
307+ uq = m1 .update (field = 'C' )
308+ await uq .apply ()
309+
310+ # lookup
311+ assert set (tuple (x ) for x in await ModelWithCustomColumnNames .select ('id' ).gino .all ()) == {(1 ,), (2 ,)}
312+ assert (await ModelWithCustomColumnNames .get (2 )).field == "B"
313+ assert (await ModelWithCustomColumnNames .get (1 )).field == "C"
314+ assert await ModelWithCustomColumnNames .get (3 ) is None
315+
316+ # delete
317+ assert (await ModelWithCustomColumnNames .delete .where (ModelWithCustomColumnNames .id == 3 ).gino .status ())[0 ][- 1 ] == '0'
318+ assert (await ModelWithCustomColumnNames .delete .where (ModelWithCustomColumnNames .id == 2 ).gino .status ())[0 ][- 1 ] == '1'
319+ assert set (tuple (x ) for x in await ModelWithCustomColumnNames .select ('id' ).gino .all ()) == {(1 ,)}
320+ finally :
321+ await ModelWithCustomColumnNames .gino .drop ()
0 commit comments