Module: Upkeep::ActiveRecordQuery::Schema
- Defined in:
- lib/upkeep/active_record_query.rb
Class Method Summary collapse
Class Method Details
.for(connection, statement) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/upkeep/active_record_query.rb', line 176 def for(connection, statement) physical_tables(statement).each_with_object({}) do |table, schema| lookup_name = table.split(".").last columns = begin connection.schema_cache.columns(lookup_name).to_h do |column| [column.name, column.sql_type] end rescue ActiveRecord::StatementInvalid {} end schema[table] = columns.freeze unless columns.empty? end.freeze end |
.physical_tables(statement) ⇒ Object
190 191 192 |
# File 'lib/upkeep/active_record_query.rb', line 190 def physical_tables(statement) collect_sources(statement, visible_ctes: Set.new).uniq.sort end |