#NEWLINE# def _get_portable_table_column_definition( self , table_column ) : #NEWLINE# #INDENT# if ( ( table_column [ 'type' ] . lower ( ) == 'varchar' ) or ( table_column [ 'type' ] == 'bpchar' ) ) : #NEWLINE# #INDENT# length = re . sub ( '.*\\(([0-9]*)\\).*' , '\\1' , table_column [ 'complete_type' ] ) #NEWLINE# table_column [ 'length' ] = length #NEWLINE# #UNINDENT# autoincrement = False #NEWLINE# match = re . match ( "^nextval\\('?(.*)'?(::.*)?\\)$" , str ( table_column [ 'default' ] ) ) #NEWLINE# if match : #NEWLINE# #INDENT# table_column [ 'sequence' ] = match . group ( 1 ) #NEWLINE# table_column [ 'default' ] = None #NEWLINE# autoincrement = True #NEWLINE# #UNINDENT# match = re . match ( "^'?([^']*)'?::.*$" , str ( table_column [ 'default' ] ) ) #NEWLINE# if match : #NEWLINE# #INDENT# table_column [ 'default' ] = match . group ( 1 ) #NEWLINE# #UNINDENT# if ( str ( table_column [ 'default' ] ) . find ( 'NULL' ) == 0 ) : #NEWLINE# #INDENT# table_column [ 'default' ] = None #NEWLINE# #UNINDENT# if ( 'length' in table_column ) : #NEWLINE# #INDENT# length = table_column [ 'length' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# length = None #NEWLINE# #UNINDENT# if ( ( length == '-1' ) and ( 'atttypmod' in table_column ) ) : #NEWLINE# #INDENT# length = ( table_column [ 'atttypmod' ] - 4 ) #NEWLINE# #UNINDENT# if ( ( length is None ) or ( not length . isdigit ( ) ) or ( int ( column ) <= 0 ) ) : #NEWLINE# #INDENT# length = None #NEWLINE# #UNINDENT# fixed = None #NEWLINE# if ( 'name' not in table_column ) : #NEWLINE# #INDENT# table_column [ 'name' ] = '' #NEWLINE# #UNINDENT# precision = None #NEWLINE# scale = None #NEWLINE# db_type = table_column [ 'type' ] . lower ( ) #NEWLINE# type = self . _platform . get_type_mapping ( db_type ) #NEWLINE# if ( db_type in [ 'smallint' , 'int2' ] ) : #NEWLINE# #INDENT# length = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type in [ 'int' , 'int4' , 'integer' ] ) : #NEWLINE# #INDENT# length = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type in [ 'int8' , 'bigint' ] ) : #NEWLINE# #INDENT# length = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type in [ 'bool' , 'boolean' ] ) : #NEWLINE# #INDENT# if ( table_column [ 'default' ] == 'true' ) : #NEWLINE# #INDENT# table_column [ 'default' ] = True #NEWLINE# #UNINDENT# if ( table_column [ 'default' ] == 'false' ) : #NEWLINE# #INDENT# table_column [ 'default' ] = False #NEWLINE# #UNINDENT# length = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type == 'text' ) : #NEWLINE# #INDENT# fixed = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type in [ 'varchar' , 'interval' , '_varchar' ] ) : #NEWLINE# #INDENT# fixed = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type in [ 'char' , 'bpchar' ] ) : #NEWLINE# #INDENT# fixed = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type in [ 'float' , 'float4' , 'float8' , 'double' , 'double precision' , 'real' , 'decimal' , 'money' , 'numeric' ] ) : #NEWLINE# #INDENT# match = re . match ( '([A-Za-z]+\\(([0-9]+),([0-9]+)\\))' , table_column [ 'complete_type' ] ) #NEWLINE# if match : #NEWLINE# #INDENT# precision = match . group ( 1 ) #NEWLINE# scale = match . group ( 2 ) #NEWLINE# length = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( db_type == 'year' ) : #NEWLINE# #INDENT# length = None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if table_column [ 'default' ] : #NEWLINE# #INDENT# match = re . match ( "('?([^']+)'?::)" , str ( table_column [ 'default' ] ) ) #NEWLINE# if match : #NEWLINE# #INDENT# table_column [ 'default' ] = match . group ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# options = { #NEWLINE# #INDENT# 'length' : length , #NEWLINE# 'notnull' : table_column [ 'isnotnull' ] , #NEWLINE# 'default' : table_column [ 'default' ] , #NEWLINE# 'primary' : ( table_column [ 'pri' ] == 't' ) , #NEWLINE# 'precision' : precision , #NEWLINE# 'scale' : scale , #NEWLINE# 'fixed' : fixed , #NEWLINE# 'unsigned' : False , #NEWLINE# 'autoincrement' : autoincrement , #NEWLINE# #UNINDENT# } #NEWLINE# column = Column ( table_column [ 'field' ] , type , options ) #NEWLINE# return column