From c81a01add2d3e5980b09c7784f1480d2bec940ea Mon Sep 17 00:00:00 2001 From: sureshantony Date: Mon, 12 Jan 2015 16:51:54 -0800 Subject: [PATCH] adding option return data types and default value --- mysql2pgsql/lib/postgres_writer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mysql2pgsql/lib/postgres_writer.py b/mysql2pgsql/lib/postgres_writer.py index f3fe306..cb71acf 100644 --- a/mysql2pgsql/lib/postgres_writer.py +++ b/mysql2pgsql/lib/postgres_writer.py @@ -30,7 +30,7 @@ def column_type(self, column): self.column_types[hash_key] = self.column_type_info(column).split(" ")[0] return self.column_types[hash_key] - def column_type_info(self, column): + def column_type_info(self, column, return_tuple=False): """ """ null = "" if column['null'] else " NOT NULL" @@ -126,9 +126,13 @@ def get_type(column): default, column_type = get_type(column) if column.get('auto_increment', None): - return '%s DEFAULT nextval(\'"%s_%s_seq"\'::regclass) NOT NULL' % ( - column_type, column['table_name'], column['name']) - + if return_tuple: + return (column_type, (default if not default == None else ''), null) + else: + return '%s DEFAULT nextval(\'"%s_%s_seq"\'::regclass) NOT NULL' % ( + column_type, column['table_name'], column['name']) + if return_tuple: + return (column_type, (default if not default == None else ''), null) return '%s%s%s' % (column_type, (default if not default == None else ''), null) def table_comments(self, table):