@@ -586,6 +586,8 @@ async def atestDescription(self, fw):
586586 con = apsw .Connection ("" )
587587 acon = await apsw .Connection .as_async ("" )
588588
589+ has_full = hasattr (apsw .Cursor , "description_full" )
590+
589591 try :
590592 tables = []
591593
@@ -622,10 +624,13 @@ async def atestDescription(self, fw):
622624 for _ in range (20 ):
623625 sql += f'SELECT * FROM "{ random .choice (tables )} " LIMIT { random .randint (0 , 10 )} ;'
624626 table = random .choice (tables )
625- emsql += f'INSERT INTO "{ table } " ("{ random .choice (table_columns [table ])} ") VALUES(?) RETURNING rowid ;'
626- emvalues .append ((random .randint (0 , 10 ),))
627+ emsql += (
628+ f'INSERT INTO "{ table } " ("{ random .choice (table_columns [table ])} ") VALUES(:foo) RETURNING rowid ;'
629+ )
630+ emvalues .append ({"foo" : random .randint (0 , 10 )})
627631
628632 for prefetch in (1 , 2 , 3 , 7 , 10 , 50 ):
633+ print (f"{ prefetch = } " )
629634 apsw .async_cursor_prefetch .set (prefetch )
630635 # regular execute mode
631636 sync_cur = con .execute (sql )
@@ -634,18 +639,61 @@ async def atestDescription(self, fw):
634639 self .assertEqual (row , next (sync_cur ))
635640 self .assertEqual (sync_cur .description , async_cur .description )
636641 self .assertEqual (sync_cur .get_description (), async_cur .get_description ())
637- if hasattr ( sync_cur , "description_full" ) :
642+ if has_full :
638643 self .assertEqual (sync_cur .description_full , async_cur .description_full )
644+
645+ # check raises complete
646+ self .assertRaises (StopIteration , next , sync_cur )
647+ with self .assertRaises (StopAsyncIteration ):
648+ await anext (async_cur )
649+
650+ self .assertRaises (apsw .ExecutionCompleteError , getattr , sync_cur , "description" )
651+ self .assertRaises (apsw .ExecutionCompleteError , getattr , async_cur , "description" )
652+ self .assertRaises (apsw .ExecutionCompleteError , sync_cur .get_description )
653+ self .assertRaises (apsw .ExecutionCompleteError , async_cur .get_description )
654+ if has_full :
655+ self .assertRaises (apsw .ExecutionCompleteError , getattr , sync_cur , "description_full" )
656+ self .assertRaises (apsw .ExecutionCompleteError , getattr , async_cur , "description_full" )
657+
658+ # errors
659+ sql = "select 3; select syntax error"
660+ sync_cur = con .execute (sql )
661+ async_cur = aiter (await acon .execute (sql ))
662+
663+ next (sync_cur )
664+ await anext (async_cur )
665+
666+ self .assertRaises (apsw .SQLError , next , sync_cur )
667+ with self .assertRaises (apsw .SQLError ):
668+ await anext (async_cur )
669+
670+ self .assertRaises (StopIteration , next , sync_cur )
671+ with self .assertRaises (StopAsyncIteration ):
672+ await anext (async_cur )
673+
639674 # executemany mode
640675 sync_cur = con .executemany (emsql , emvalues )
641676 async_cur = await acon .executemany (emsql , emvalues )
642677 async for row in async_cur :
643678 self .assertEqual (row , next (sync_cur ))
644679 self .assertEqual (sync_cur .description , async_cur .description )
645680 self .assertEqual (sync_cur .get_description (), async_cur .get_description ())
646- if hasattr ( sync_cur , "description_full" ) :
681+ if has_full :
647682 self .assertEqual (sync_cur .description_full , async_cur .description_full )
648683
684+ # check raises complete
685+ self .assertRaises (StopIteration , next , sync_cur )
686+ with self .assertRaises (StopAsyncIteration ):
687+ await anext (async_cur )
688+
689+ self .assertRaises (apsw .ExecutionCompleteError , getattr , sync_cur , "description" )
690+ self .assertRaises (apsw .ExecutionCompleteError , getattr , async_cur , "description" )
691+ self .assertRaises (apsw .ExecutionCompleteError , sync_cur .get_description )
692+ self .assertRaises (apsw .ExecutionCompleteError , async_cur .get_description )
693+ if has_full :
694+ self .assertRaises (apsw .ExecutionCompleteError , getattr , sync_cur , "description_full" )
695+ self .assertRaises (apsw .ExecutionCompleteError , getattr , async_cur , "description_full" )
696+
649697 finally :
650698 con .close (True )
651699 acon .close (True )
0 commit comments