4
4
from sqlalchemy .engine import reflection
5
5
from sqlalchemy .ext .compiler import compiles
6
6
from sqlalchemy .sql .expression import BindParameter , Executable , ClauseElement
7
- from sqlalchemy .types import VARCHAR , NullType
7
+ from sqlalchemy .types import VARCHAR , NullType , BigInteger , Integer
8
8
9
9
10
10
class RedShiftDDLCompiler (PGDDLCompiler ):
@@ -75,17 +75,16 @@ def post_create_table(self, table):
75
75
return text
76
76
77
77
def get_column_specification (self , column , ** kwargs ):
78
- # aron - Apr 21, 2014: Redshift doesn't support serial types. So I
79
- # removed support for them here.
80
78
colspec = self .preparer .format_column (column )
81
- colspec += " " + self .dialect .type_compiler .process (column .type )
82
79
83
- colspec += self ._fetch_redshift_column_attributes (column )
80
+ colspec += " " + self .dialect . type_compiler . process (column . type )
84
81
85
82
default = self .get_column_default_string (column )
86
83
if default is not None :
87
84
colspec += " DEFAULT " + default
88
85
86
+ colspec += self ._fetch_redshift_column_attributes (column )
87
+
89
88
if not column .nullable :
90
89
colspec += " NOT NULL"
91
90
return colspec
@@ -95,6 +94,10 @@ def _fetch_redshift_column_attributes(self, column):
95
94
if not hasattr (column , 'info' ):
96
95
return text
97
96
info = column .info
97
+ identity = info .get ('identity' , None )
98
+ if identity :
99
+ text += " IDENTITY({0},{1})" .format (identity [0 ], identity [1 ])
100
+
98
101
encode = info .get ('encode' , None )
99
102
if encode :
100
103
text += " ENCODE " + encode
0 commit comments