File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11import datetime
22from decimal import Decimal
3+ from sqlalchemy import func
34from sqlalchemy .sql import sqltypes
45from sqlalchemy .types import UserDefinedType
56from uuid import UUID as _python_UUID
@@ -236,6 +237,15 @@ def process(value):
236237
237238 return process
238239
240+ class comparator_factory (UserDefinedType .Comparator ):
241+ def func (self , funcname : str , other ):
242+ if not isinstance (other , list ) and not isinstance (other , tuple ):
243+ raise ValueError ("expected list or tuple, got '%s'" % type (other ))
244+ irislist = IRISList ()
245+ for item in other :
246+ irislist .add (item )
247+ return getattr (func , funcname )(self , irislist .getBuffer ())
248+
239249
240250class BIT (sqltypes .TypeEngine ):
241251 __visit_name__ = "BIT"
Original file line number Diff line number Diff line change @@ -321,3 +321,19 @@ def test_listbuild(self):
321321 (None ,),
322322 ],
323323 )
324+ self ._assert_result (
325+ select (self .tables .data ).where (self .tables .data .c .val == [1.0 ] * 50 ),
326+ [
327+ ([1.0 ] * 50 ,),
328+ ],
329+ )
330+
331+ self ._assert_result (
332+ select (
333+ self .tables .data ,
334+ self .tables .data .c .val .func ("$listsame" , [1.0 ] * 50 ).label ("same" ),
335+ ).limit (1 ),
336+ [
337+ ([1.0 ] * 50 , 1 ),
338+ ],
339+ )
You can’t perform that action at this time.
0 commit comments