Skip to content

Commit

Permalink
Fix cols_stmt handling of multiple nonoid_fields_w_objectid
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-M-Waldman committed Oct 11, 2024
1 parent 610c3b6 commit a53c2e9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions databridge_etl_tools/oracle/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,15 @@ def load(self):

# Get columns from prod oracle table
cursor = self.conn.cursor()
cols_stmt = f'''SELECT LISTAGG(column_name, ', ') WITHIN GROUP (ORDER BY column_id)
FROM all_tab_cols
WHERE table_name = '{self.table_name.upper()}'
AND owner = '{self.table_schema.upper()}'
AND column_name not like 'SYS\_%' ESCAPE '\\'
AND (column_name not like '%OBJECTID%' or column_name in ('{','.join([ f.upper() for f in self.nonoid_fields_w_objectid])}'))
'''
cols_stmt = f'''
SELECT LISTAGG(column_name, ', ')
WITHIN GROUP (ORDER BY column_id)
FROM all_tab_cols
WHERE table_name = '{self.table_name.upper()}'
AND owner = '{self.table_schema.upper()}'
AND column_name not like 'SYS\_%' ESCAPE '\\'
AND (column_name not like '%OBJECTID%' or column_name in ({','.join(["'" + f.upper() + "'" for f in self.nonoid_fields_w_objectid])}))
'''
cursor.execute(cols_stmt)
cols = cursor.fetchall()[0][0]
assert cols, f'Could not fetch columns, does the table exist?\n Statement: {cols_stmt}'
Expand Down

0 comments on commit a53c2e9

Please sign in to comment.