@@ -165,6 +165,15 @@ def step(self, val):
165165 def finalize (self ):
166166 return self .val
167167
168+ class AggrText :
169+ def __init__ (self ):
170+ self .txt = ""
171+ def step (self , txt ):
172+ self .txt = self .txt + txt
173+ def finalize (self ):
174+ return self .txt
175+
176+
168177class FunctionTests (unittest .TestCase ):
169178 def setUp (self ):
170179 self .con = sqlite .connect (":memory:" )
@@ -399,6 +408,7 @@ def setUp(self):
399408 self .con .create_aggregate ("checkType" , 2 , AggrCheckType )
400409 self .con .create_aggregate ("checkTypes" , - 1 , AggrCheckTypes )
401410 self .con .create_aggregate ("mysum" , 1 , AggrSum )
411+ self .con .create_aggregate ("aggtxt" , 1 , AggrText )
402412
403413 def tearDown (self ):
404414 #self.cur.close()
@@ -495,6 +505,15 @@ def test_aggr_no_match(self):
495505 val = cur .fetchone ()[0 ]
496506 self .assertIsNone (val )
497507
508+ def test_aggr_text (self ):
509+ cur = self .con .cursor ()
510+ for txt in ["foo" , "1\x00 2" ]:
511+ with self .subTest (txt = txt ):
512+ cur .execute ("select aggtxt(?) from test" , (txt ,))
513+ val = cur .fetchone ()[0 ]
514+ self .assertEqual (val , txt )
515+
516+
498517class AuthorizerTests (unittest .TestCase ):
499518 @staticmethod
500519 def authorizer_cb (action , arg1 , arg2 , dbname , source ):
0 commit comments