@@ -653,6 +653,20 @@ def visit_drop_schema(self, drop, **kw):
653
653
def visit_check_constraint (self , constraint , ** kw ):
654
654
pass
655
655
656
+ def create_table_constraints (self , table , ** kw ):
657
+ description = ""
658
+ comment = table .comment
659
+ if comment :
660
+ # hack to keep \r, kind of
661
+ comment = comment .replace ('\r ' , '\n \t ' )
662
+ literal = self .sql_compiler .render_literal_value (comment , sqltypes .String ())
663
+ description = "%DESCRIPTION " + literal
664
+
665
+ constraints = super ().create_table_constraints (table , ** kw )
666
+ if constraints and description :
667
+ description = ", \n \t " + description
668
+ return constraints + description
669
+
656
670
def visit_add_constraint (self , create , ** kw ):
657
671
if isinstance (create .element , schema .CheckConstraint ):
658
672
raise exc .CompileError ("Can't add CHECK constraint" )
@@ -701,6 +715,7 @@ def get_column_specification(self, column, **kwargs):
701
715
702
716
comment = column .comment
703
717
if comment is not None :
718
+ comment = comment .replace ('\r ' , '\n \t ' )
704
719
literal = self .sql_compiler .render_literal_value (comment , sqltypes .String ())
705
720
colspec .append ("%DESCRIPTION " + literal )
706
721
@@ -883,6 +898,12 @@ class IRISDialect(default.DefaultDialect):
883
898
type_compiler = IRISTypeCompiler
884
899
execution_ctx_cls = IRISExecutionContext
885
900
901
+ insert_returning = True
902
+ insert_executemany_returning = True
903
+ insert_executemany_returning_sort_by_parameter_order = True
904
+ update_executemany_returning = False
905
+ delete_executemany_returning = False
906
+
886
907
construct_arguments = [
887
908
(schema .Index , {"include" : None }),
888
909
]
@@ -1105,6 +1126,38 @@ def get_schema(self, schema=None):
1105
1126
return "SQLUser"
1106
1127
return schema
1107
1128
1129
+ @reflection .cache
1130
+ def get_table_options (self , connection , table_name , schema = None , ** kw ):
1131
+ if not self .has_table (connection = connection , table_name = table_name , schema = schema ):
1132
+ raise exc .NoSuchTableError (
1133
+ f"{ schema } .{ table_name } " if schema else table_name
1134
+ ) from None
1135
+ return {}
1136
+
1137
+ @reflection .cache
1138
+ def get_table_comment (self , connection , table_name , schema = None , ** kw ):
1139
+ if not self .has_table (connection = connection , table_name = table_name , schema = schema ):
1140
+ raise exc .NoSuchTableError (
1141
+ f"{ schema } .{ table_name } " if schema else table_name
1142
+ ) from None
1143
+
1144
+ tables = ischema .tables
1145
+ schema_name = self .get_schema (schema )
1146
+
1147
+ s = sql .select (tables .c .description ).where (
1148
+ sql .and_ (
1149
+ tables .c .table_schema == str (schema_name ),
1150
+ tables .c .table_name == str (table_name ),
1151
+ )
1152
+ )
1153
+ comment = connection .execute (s ).scalar ()
1154
+ if comment :
1155
+ # make it as \r
1156
+ comment = comment .replace (' \t \t \t \t ' , '\r ' )
1157
+ # restore \n
1158
+ comment = comment .replace (' \t \t \t ' , '\n ' )
1159
+ return {"text" : comment }
1160
+
1108
1161
@reflection .cache
1109
1162
def get_schema_names (self , connection , ** kw ):
1110
1163
s = sql .select (ischema .schemata .c .schema_name ).order_by (
@@ -1131,7 +1184,7 @@ def get_table_names(self, connection, schema=None, **kw):
1131
1184
return table_names
1132
1185
1133
1186
@reflection .cache
1134
- def get_temp_table_names (self , connection , dblink = None , ** kw ):
1187
+ def get_temp_table_names (self , connection , ** kw ):
1135
1188
tables = ischema .tables
1136
1189
s = (
1137
1190
sql .select (tables .c .table_name )
@@ -1598,6 +1651,7 @@ def get_multi_columns(
1598
1651
columns .c .column_default ,
1599
1652
columns .c .collation_name ,
1600
1653
columns .c .auto_increment ,
1654
+ columns .c .description ,
1601
1655
)
1602
1656
.select_from (columns )
1603
1657
.where (
@@ -1650,7 +1704,12 @@ def get_multi_columns(
1650
1704
sqlComputeCode = row [property .c .SqlComputeCode ]
1651
1705
calculated = row [property .c .Calculated ]
1652
1706
transient = row [property .c .Transient ]
1653
- # description = row[columns.c.description]
1707
+ comment = row [columns .c .description ]
1708
+ if comment :
1709
+ # make it as \r
1710
+ comment = comment .replace (' \t \t \t \t ' , '\r ' )
1711
+ # restore \n
1712
+ comment = comment .replace (' \t \t \t ' , '\n ' )
1654
1713
1655
1714
coltype = self .ischema_names .get (type_ , None )
1656
1715
@@ -1696,7 +1755,7 @@ def get_multi_columns(
1696
1755
"nullable" : nullable ,
1697
1756
"default" : default ,
1698
1757
"autoincrement" : autoincrement ,
1699
- # "comment": description ,
1758
+ "comment" : comment ,
1700
1759
}
1701
1760
if sqlComputeCode and "set {*} = " in sqlComputeCode .lower ():
1702
1761
sqltext = sqlComputeCode
0 commit comments