@@ -526,6 +526,30 @@ def visit_not_regexp_match_op_binary(self, binary, operator, **kw):
526
526
# InterSystems use own format for %MATCHES, it does not support Regular Expressions
527
527
raise exc .CompileError ("InterSystems IRIS does not support REGEXP" )
528
528
529
+ def visit_case (self , clause , ** kwargs ):
530
+ x = "CASE "
531
+ if clause .value is not None :
532
+ x += clause .value ._compiler_dispatch (self , ** kwargs ) + " "
533
+ for cond , result in clause .whens :
534
+ x += (
535
+ "WHEN "
536
+ + cond ._compiler_dispatch (self , ** kwargs )
537
+ + " THEN "
538
+ # Explicit CAST required on 2023.1
539
+ + (self .visit_cast (sql .cast (result , result .type ), ** kwargs )
540
+ if isinstance (result , sql .elements .BindParameter ) else result ._compiler_dispatch (self , ** kwargs ))
541
+ + " "
542
+ )
543
+ if clause .else_ is not None :
544
+ x += (
545
+ "ELSE "
546
+ + (self .visit_cast (sql .cast (clause .else_ , clause .else_ .type ), ** kwargs )
547
+ if isinstance (clause .else_ , sql .elements .BindParameter ) else clause .else_ ._compiler_dispatch (self , ** kwargs ))
548
+ + " "
549
+ )
550
+ x += "END"
551
+ return x
552
+
529
553
530
554
class IRISDDLCompiler (sql .compiler .DDLCompiler ):
531
555
"""IRIS syntactic idiosyncrasies"""
@@ -850,15 +874,15 @@ def create_connect_args(self, url):
850
874
opts ["autoCommit" ] = False
851
875
852
876
opts ["embedded" ] = self .embedded
853
- if "@" in opts ["hostname" ]:
877
+ if opts [ "hostname" ] and "@" in opts ["hostname" ]:
854
878
_h = opts ["hostname" ].split ("@" )
855
- opts ["password" ] += "@" + _h [0 : len (_h ) - 1 ].join ("@" )
879
+ opts ["password" ] += "@" + _h [0 : len (_h ) - 1 ].join ("@" )
856
880
opts ["hostname" ] = _h [len (_h ) - 1 ]
857
881
858
882
return ([], opts )
859
883
860
884
_debug_queries = False
861
- # _debug_queries = True
885
+ _debug_queries = True
862
886
863
887
def _debug (self , query , params , many = False ):
864
888
from decimal import Decimal
0 commit comments