Skip to content

Commit a84eb06

Browse files
author
Roman Klesel
committed
PK not necessarily interger type
1 parent 06626c3 commit a84eb06

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mysql2pgsql/lib/postgres_writer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ def column_type(self, column):
3333
def column_type_info(self, column):
3434
"""
3535
"""
36-
if column.get('auto_increment', None):
37-
return 'integer DEFAULT nextval(\'%s_%s_seq\'::regclass) NOT NULL' % (
38-
column['table_name'], column['name'])
39-
4036
null = "" if column['null'] else " NOT NULL"
4137

4238
def get_type(column):
@@ -128,6 +124,11 @@ def get_type(column):
128124
raise Exception('unknown %s' % column['type'])
129125

130126
default, column_type = get_type(column)
127+
128+
if column.get('auto_increment', None):
129+
return '%s DEFAULT nextval(\'%s_%s_seq\'::regclass) NOT NULL' % (
130+
column_type, column['table_name'], column['name'])
131+
131132
return '%s%s%s' % (column_type, (default if not default == None else ''), null)
132133

133134
def process_row(self, table, row):

0 commit comments

Comments
 (0)