99from sqlalchemy .sql import util as sql_util
1010from sqlalchemy .sql import between
1111from sqlalchemy .sql import func
12- from sqlalchemy import sql
12+ from sqlalchemy import sql , text
1313from sqlalchemy import util
1414from sqlalchemy import types as sqltypes
1515
@@ -393,6 +393,9 @@ def translate_select_structure(self, select_stmt, **kwargs):
393393 for elem in select ._order_by_clause .clauses
394394 ]
395395
396+ if not _order_by_clauses :
397+ _order_by_clauses = [text ('%id' )]
398+
396399 limit_clause = self ._get_limit_or_fetch (select )
397400 offset_clause = select ._offset_clause
398401
@@ -440,6 +443,44 @@ def visit_drop_schema(self, drop, **kw):
440443 def visit_check_constraint (self , constraint , ** kw ):
441444 raise exc .CompileError ("Check CONSTRAINT not supported" )
442445
446+ def get_column_specification (self , column , ** kwargs ):
447+
448+ colspec = [
449+ self .preparer .format_column (column ),
450+ ]
451+
452+ if (
453+ column .primary_key
454+ and column is column .table ._autoincrement_column
455+ ):
456+ colspec .append ("SERIAL" )
457+ else :
458+ colspec .append (
459+ self .dialect .type_compiler .process (
460+ column .type ,
461+ type_expression = column ,
462+ identifier_preparer = self .preparer ,
463+ )
464+ )
465+
466+ if column .computed is not None :
467+ colspec .append (self .process (column .computed ))
468+ default = self .get_column_default_string (column )
469+ if default is not None :
470+ colspec .append ("DEFAULT " + default )
471+
472+ if not column .nullable :
473+ colspec .append ("NOT NULL" )
474+
475+ comment = column .comment
476+ if comment is not None :
477+ literal = self .sql_compiler .render_literal_value (
478+ comment , sqltypes .String ()
479+ )
480+ colspec .append ("%%DESCRIPTION " + literal )
481+
482+ return " " .join (colspec )
483+
443484
444485class IRISTypeCompiler (compiler .GenericTypeCompiler ):
445486 def visit_boolean (self , type_ , ** kw ):
@@ -536,11 +577,13 @@ def process(value):
536577
537578
538579class IRISDialect (default .DefaultDialect ):
539- driver = 'iris'
580+
581+ name = 'iris'
540582
541583 default_schema_name = "SQLUser"
542584
543585 default_paramstyle = "format"
586+ supports_statement_cache = True
544587
545588 supports_native_decimal = True
546589 supports_sane_rowcount = True
@@ -551,7 +594,6 @@ class IRISDialect(default.DefaultDialect):
551594
552595 supports_sequences = False
553596
554- supports_statement_cache = False
555597 postfetch_lastrowid = False
556598 non_native_boolean_check_constraint = False
557599 supports_simple_order_by_label = False
@@ -610,6 +652,7 @@ def _fix_for_params(self, query, params, many=False):
610652
611653 def do_execute (self , cursor , query , params , context = None ):
612654 query , params = self ._fix_for_params (query , params )
655+ # print('do_execute', query, params)
613656 cursor .execute (query , params )
614657
615658 def do_executemany (self , cursor , query , params , context = None ):
@@ -903,7 +946,7 @@ def get_columns(self, connection, table_name, schema=None, **kw):
903946 ):
904947 if charlen == - 1 :
905948 charlen = None
906- kwargs ["length" ] = charlen
949+ kwargs ["length" ] = int ( charlen )
907950 if collation :
908951 kwargs ["collation" ] = collation
909952 if coltype is None :
@@ -914,10 +957,10 @@ def get_columns(self, connection, table_name, schema=None, **kw):
914957 coltype = sqltypes .NULLTYPE
915958 else :
916959 if issubclass (coltype , sqltypes .Numeric ):
917- kwargs ["precision" ] = numericprec
960+ kwargs ["precision" ] = int ( numericprec )
918961
919962 if not issubclass (coltype , sqltypes .Float ):
920- kwargs ["scale" ] = numericscale
963+ kwargs ["scale" ] = int ( numericscale )
921964
922965 coltype = coltype (** kwargs )
923966
0 commit comments