Class: Dart::Reflection::SequelTable::ForeignKeyFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/dart/reflection/sequel_table/foreign_key_finder.rb

Instance Method Summary collapse

Instance Method Details

#foreign_keys_for(relation, schema) ⇒ Array<ForeignKeyInfo>

Returns the set of foreign keys on the given relation based on foreign key constraints defined in the db

Parameters:

  • relation (Relation)

    the relation to search

  • schema (Schema)

    defines the set of referenceable tables (and the db to search)

Returns:

  • (Array<ForeignKeyInfo>)

    info for foreign keys in the given table and db



11
12
13
14
# File 'lib/dart/reflection/sequel_table/foreign_key_finder.rb', line 11

def foreign_keys_for(relation, schema)
  rows = schema.execute!(constraint_query(relation.table_name))
  rows.all.map { |attrs| ForeignKeyInfo.from_hash(attrs) }
end