Skip to content

Commit

Permalink
Merge pull request #24 from jcarlosgalvezm/hotfix/1.6.2
Browse files Browse the repository at this point in the history
Hotfix/1.6.2
  • Loading branch information
vcapelca authored Jul 28, 2017
2 parents 8886d96 + 4e3ca11 commit a974b60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='slippinj',
version='1.6.1',
version='1.6.2',
author='Data Architects SCM Spain',
author_email='[email protected]',
packages=find_packages('src'),
Expand Down
12 changes: 8 additions & 4 deletions src/slippinj/databases/drivers/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def __get_columns_for_tables(self, tables):
self.__logger.debug('Getting columns information')

query_with_owner = "AND owner = '{schema}'".format(schema=self.__db_schema)
info_query = "SELECT table_name, column_name, data_type, data_length, nullable, data_default " \
"FROM ALL_TAB_COLS " \
info_query = "SELECT table_name, column_name, data_type, data_length, nullable, data_default, data_scale " \
"FROM ALL_TAB_COLUMNS " \
"WHERE table_name IN ({tables}) " \
"{owner}" \
"ORDER BY COLUMN_ID".format(tables=self.__join_tables_list(tables), owner=query_with_owner if self.__db_schema else '')
Expand All @@ -94,19 +94,23 @@ def __get_columns_for_tables(self, tables):
self.__logger.debug('Columns found for table {table}'.format(table=row['TABLE_NAME']))
if not row['TABLE_NAME'] in tables_information:
tables_information[row['TABLE_NAME']] = {'columns': []}

tables_information[row['TABLE_NAME']]['columns'].append({
'source_column_name': row['COLUMN_NAME'],
'column_name': self.__get_valid_column_name(row['COLUMN_NAME']),
'source_data_type': row['DATA_TYPE'],
'data_type': row['DATA_TYPE'].lower() if row['DATA_TYPE'] not in self.__column_types else self.__column_types[
row['DATA_TYPE']],
'data_type': row['DATA_TYPE'].lower() if re.sub('TIMESTAMP(.*)', 'TIMESTAMP', row['DATA_TYPE']) not in self.__column_types else self.__map_columns(row['DATA_TYPE'], row['DATA_SCALE']),
'character_maximum_length': row['DATA_LENGTH'],
'is_nullable': row['NULLABLE'],
'column_default': row['DATA_DEFAULT'],
})

return tables_information

def __map_columns(self,datatype, datascale):
datatype = re.sub('TIMESTAMP(.*)', 'TIMESTAMP', datatype)
return 'bigint' if datatype == 'NUMBER' and datascale in (0,None) else self.__column_types[datatype]

def __get_count_for_tables(self, tables):

tables_information = {}
Expand Down

0 comments on commit a974b60

Please sign in to comment.