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