From b92371a7dd746e8373e7fd5f838bce9e7c615ea4 Mon Sep 17 00:00:00 2001 From: Douglas Soares de Andrade Date: Mon, 28 Oct 2024 14:14:15 -0400 Subject: [PATCH] Backport the fix for Rails 7.0 --- lib/odbc_adapter/schema_statements.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/odbc_adapter/schema_statements.rb b/lib/odbc_adapter/schema_statements.rb index 50238ca4..68e692be 100644 --- a/lib/odbc_adapter/schema_statements.rb +++ b/lib/odbc_adapter/schema_statements.rb @@ -10,18 +10,18 @@ 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_all || [] - stmt.drop - + table_names = [] db_regex = name_regex(current_database) schema_regex = name_regex(current_schema) - result.each_with_object([]) do |row, table_names| - next unless row[0] =~ db_regex && row[1] =~ schema_regex - 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) + stmt = @connection.prepare("SHOW TABLES IN ACCOUNT") + stmt.execute.each_hash do |row| + next unless row["database_name"] =~ db_regex && row["schema_name"] =~ schema_regex + next if respond_to?(:table_filtered?) && table_filtered?(row["schema_name"], row["kind"]) + table_names << format_case(row["name"]) end + table_names + ensure + stmt.drop end # Returns an array of view names defined in the database.