lib/activefacts/persistence/foreignkey.rb in activefacts-0.8.9 vs lib/activefacts/persistence/foreignkey.rb in activefacts-0.8.10

- old
+ new

@@ -1,22 +1,22 @@ # # ActiveFacts Relational mapping and persistence. -# A ForeignKey exists for every Reference from a Concept to another Concept that's a table. +# A ForeignKey exists for every Reference from a ObjectType to another ObjectType that's a table. # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # module ActiveFacts module Persistence class ForeignKey - # What table (Concept) is the FK from? + # What table (ObjectType) is the FK from? def from; @from; end - # What table (Concept) is the FK to? + # What table (ObjectType) is the FK to? def to; @to; end # What reference created the FK? - def reference; @reference; end + def reference; @fk_ref; end # What columns in the *from* table form the FK def from_columns; @from_columns; end # What columns in the *to* table form the identifier @@ -28,11 +28,11 @@ end end end module Metamodel #:nodoc: - class Concept + class ObjectType # When an EntityType is fully absorbed, its foreign keys are too. # Return an Array of Reference paths for such absorbed FKs def all_absorbed_foreign_key_reference_path references_from.inject([]) do |array, ref| if ref.is_simple_reference @@ -59,10 +59,10 @@ # Get the ForeignKey object for each absorbed reference path fk_ref_paths.map do |fk_ref_path| debug :fk, "\nFK: " + fk_ref_path.map{|fk_ref| fk_ref.reading }*" and " do - from_columns = columns.select{|column| + from_columns = (columns||all_columns({})).select{|column| column.references[0...fk_ref_path.size] == fk_ref_path } debug :fk, "from_columns = #{from_columns.map { |column| column.name }*", "}" absorption_path = []