@@ -524,6 +524,14 @@ def visit_mod_binary(self, binary, operator, **kw):
524524 + self .process (binary .right , ** kw )
525525 )
526526
527+ def visit_regexp_match_op_binary (self , binary , operator , ** kw ):
528+ # InterSystems use own format for %MATCHES, it does not support Regular Expressions
529+ raise exc .CompileError ("InterSystems IRIS does not support REGEXP" )
530+
531+ def visit_not_regexp_match_op_binary (self , binary , operator , ** kw ):
532+ # InterSystems use own format for %MATCHES, it does not support Regular Expressions
533+ raise exc .CompileError ("InterSystems IRIS does not support REGEXP" )
534+
527535
528536class IRISDDLCompiler (sql .compiler .DDLCompiler ):
529537 """IRIS syntactic idiosyncrasies"""
@@ -642,6 +650,27 @@ def __init__(self, dialect):
642650 super (IRISIdentifierPreparer , self ).__init__ (
643651 dialect , omit_schema = False )
644652
653+ # def _escape_identifier(self, value):
654+ # value = value.replace(self.escape_quote, self.escape_to_quote)
655+ # return value.replace(".", "_")
656+
657+ def format_column (
658+ self ,
659+ column ,
660+ use_table = False ,
661+ name = None ,
662+ table_name = None ,
663+ use_schema = False ,
664+ anon_map = None ,
665+ ):
666+ if name is None :
667+ name = column .name
668+
669+ # if '.' in name:
670+ # name = name.replace('.', '_')
671+
672+ return super ().format_column (column , use_table , name , table_name , use_schema , anon_map )
673+
645674
646675class IRISExecutionContext (default .DefaultExecutionContext ):
647676
@@ -678,6 +707,8 @@ class IRISDialect(default.DefaultDialect):
678707
679708 name = 'iris'
680709
710+ embedded = False
711+
681712 default_schema_name = "SQLUser"
682713
683714 default_paramstyle = "format"
@@ -694,6 +725,8 @@ class IRISDialect(default.DefaultDialect):
694725 supports_native_boolean = True
695726 non_native_boolean_check_constraint = False
696727
728+ supports_multivalues_insert = True
729+
697730 supports_sequences = False
698731
699732 postfetch_lastrowid = True
@@ -741,7 +774,7 @@ def _get_option(self, connection, option):
741774 def _set_option (self , connection , option , value ):
742775 cursor = connection .cursor ()
743776 # cursor = connection.cursor()
744- cursor .execute ('SELECT %SYSTEM_SQL.Util_SetOption(?, ?)' , option , value )
777+ cursor .execute ('SELECT %SYSTEM_SQL.Util_SetOption(?, ?)' , [ option , value ] )
745778 row = cursor .fetchone ()
746779 if row :
747780 return row [0 ]
@@ -805,17 +838,55 @@ def create_connect_args(self, url):
805838
806839 opts ['autoCommit' ] = False
807840
841+ opts ['embedded' ] = self .embedded
842+
808843 return ([], opts )
809844
845+ _debug_queries = False
846+ # _debug_queries = True
847+
848+ def _debug (self , query , params , many = False ):
849+ from decimal import Decimal
850+ if not self ._debug_queries :
851+ return
852+ if many :
853+ for p in params :
854+ self ._debug (query , p )
855+ return
856+ for p in params :
857+ if isinstance (p , Decimal ):
858+ v = str (p )
859+ elif p is None :
860+ v = 'NULL'
861+ else :
862+ v = '%r' % (p , )
863+ query = query .replace ('?' , v , 1 )
864+ print ('--' )
865+ print (query + ';' )
866+ print ('--' )
867+
868+ def _debug_pre (self , query , params , many = False ):
869+ print ('-- do_execute' + 'many' if many else '' )
870+ if not self ._debug_queries :
871+ return
872+ for line in query .split ('\n ' ):
873+ print ('-- ' , line )
874+ if many :
875+ print (params )
876+ else :
877+ for p in params :
878+ print ('-- @param = %r' % (p , ))
879+
810880 def do_execute (self , cursor , query , params , context = None ):
881+ self ._debug (query , params )
811882 cursor .execute (query , params )
812883
813884 def do_executemany (self , cursor , query , params , context = None ):
885+ self ._debug (query , params , True )
814886 cursor .executemany (query , params )
815887
816888 def do_begin (self , connection ):
817889 pass
818- # connection.cursor().execute("START TRANSACTION")
819890
820891 def do_rollback (self , connection ):
821892 connection .rollback ()
@@ -1171,7 +1242,10 @@ def get_columns(self, connection, table_name, schema=None, **kw):
11711242 ):
11721243 if charlen == - 1 :
11731244 charlen = None
1174- kwargs ["length" ] = int (charlen )
1245+ try :
1246+ kwargs ["length" ] = int (charlen )
1247+ except ValueError :
1248+ kwargs ["length" ] = 0
11751249 if collation :
11761250 kwargs ["collation" ] = collation
11771251 if coltype is None :
0 commit comments