Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

adding option return data types and default value #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mysql2pgsql/lib/postgres_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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):
Expand Down