class TableSaw::Queries::ForeignKeyRelationships

Constants

QUERY

Public Instance Methods

constraint_names() click to toggle source
# File lib/table_saw/queries/foreign_key_relationships.rb, line 22
def constraint_names
  @constraint_names ||= result.each_with_object(Hash.new { |h, k| h[k] = [] }) do |row, memo|
    memo[row['from_table']].push(row['constraint_name'])
  end
end
foreign_keys() click to toggle source
# File lib/table_saw/queries/foreign_key_relationships.rb, line 28
def foreign_keys
  @foreign_keys ||= result.map do |row|
    TableSaw::ForeignKey.new(name: row['constraint_name'],
                             from_table: row['from_table'], from_column: row['from_column'],
                             to_table: row['to_table'], to_column: row['to_column'])
  end
end

Private Instance Methods

result() click to toggle source
# File lib/table_saw/queries/foreign_key_relationships.rb, line 38
def result
  @result ||= TableSaw::Connection.exec(QUERY)
end