Commit b007666b by cuong.tran

Fix #282 with error "foreign_keys is not implemented"

parent a0682a49
...@@ -288,7 +288,9 @@ module AnnotateModels ...@@ -288,7 +288,9 @@ module AnnotateModels
fk_info = "#\n# Foreign Keys\n#\n" fk_info = "#\n# Foreign Keys\n#\n"
end end
foreign_keys = klass.connection.respond_to?(:foreign_keys) ? klass.connection.foreign_keys(klass.table_name) : [] return "" unless klass.connection.supports_foreign_keys? && klass.connection.respond_to?(:foreign_keys)
foreign_keys = klass.connection.foreign_keys(klass.table_name)
return "" if foreign_keys.empty? return "" if foreign_keys.empty?
max_size = foreign_keys.collect{|fk| fk.name.size}.max + 1 max_size = foreign_keys.collect{|fk| fk.name.size}.max + 1
......
...@@ -17,6 +17,7 @@ describe AnnotateModels do ...@@ -17,6 +17,7 @@ describe AnnotateModels do
double("Conn", double("Conn",
:indexes => indexes, :indexes => indexes,
:foreign_keys => foreign_keys, :foreign_keys => foreign_keys,
:supports_foreign_keys? => true,
) )
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment