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 1
1
import datetime
2
2
from decimal import Decimal
3
+ from sqlalchemy import func
3
4
from sqlalchemy .sql import sqltypes
4
5
from sqlalchemy .types import UserDefinedType
5
6
from uuid import UUID as _python_UUID
@@ -236,6 +237,15 @@ def process(value):
236
237
237
238
return process
238
239
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
+
239
249
240
250
class BIT (sqltypes .TypeEngine ):
241
251
__visit_name__ = "BIT"
Original file line number Diff line number Diff line change @@ -321,3 +321,19 @@ def test_listbuild(self):
321
321
(None ,),
322
322
],
323
323
)
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