Skip to content

Commit

Permalink
Opt-in to handle errors caused by long comments on tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrown-msb committed Jun 26, 2024
1 parent c57096e commit cef9345
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/odbc_adapter/schema_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ def native_database_types
# Returns an array of table names, for database tables visible on the
# current connection.
def tables(_name = nil)
stmt = @connection.tables
result = stmt.fetch || []
stmt.drop
begin
if @config.key?(:silo_fetch_all_tables) && @config[:silo_fetch_all_tables]
stmt = @connection.prepare("SHOW TABLES")
col_idx = stmt.columns.keys.map.with_index.to_h
q_res = stmt.execute.fetch_all
result = q_res.map { |row| [row[col_idx["database_name"]], row[col_idx["schema_name"]], row[col_idx["name"]], row[col_idx["kind"]], row[col_idx["comment"]]] }
else
stmt = @connection.tables
result = stmt.fetch_all || []
end

result.each_with_object([]) do |row, table_names|
schema_name, table_name, table_type = row[1..3]
next if respond_to?(:table_filtered?) && table_filtered?(schema_name, table_type)
result ||= []

table_names << format_case(table_name)
result.each_with_object([]) do |row, table_names|
schema_name, table_name, table_type = row[1..3]
next if respond_to?(:table_filtered?) && table_filtered?(schema_name, table_type)

table_names << format_case(table_name)
end
ensure
stmt.drop
end
end

Expand Down

0 comments on commit cef9345

Please sign in to comment.