Skip to content


Subversion checkout URL

You can clone with
Download ZIP


add support for composite_primary_keys #105

merged 1 commit into from

6 participants


Fix for: #89

Wrote test, but wasn't able to get dependency issue with wrong gem worked out. Tested manually and works as spec expects.


Sorry about that -- I wrote Wrong and it's had some dependency problems for a few months now... Something to do with Ryan updating his various ruby parsing gems.

Thanks for the patch! I'll look at it soon.


+1 would like this merged.

@turadg turadg merged commit 8bd159c into ctran:master

1 check failed

Details default The Travis build failed

Until Travis is working again, I'll take @garysweaver at his word that this works. ;)




Since Travis isn't working for you, I'm just chiming in with feedback that this works for my 'composite_primary_keys' models that annotate previous would not handle.

Thanks to all of you for your work on this gem.


thanks @mattgarison for the confirmation. and of course thanks @garysweaver for making it work. :smile:


Been waiting for this for a while, any gem release planned?

@turadg turadg referenced this pull request from a commit
@turadg turadg fix spec for composite_primary_keys #105 99cc11e

@captainmike I just pushed 2.6.0.beta2 to rubygems


great! will check it out.



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 9, 2012
  1. @garysweaver
This page is out of date. Refresh to see the latest.
2  lib/annotate/annotate_models.rb
@@ -113,7 +113,7 @@ def get_schema_info(klass, header, options = {})
attrs = []
attrs << "default(#{quote(col.default)})" unless col.default.nil?
attrs << "not null" unless col.null
- attrs << "primary key" if klass.primary_key && == klass.primary_key.to_sym
+ attrs << "primary key" if klass.primary_key && (klass.primary_key.is_a?(Array) ? klass.primary_key.collect{|c|c.to_sym}.include?( : == klass.primary_key.to_sym)
col_type = (col.type || col.sql_type).to_s
if col_type == "decimal"
19 spec/annotate/annotate_models_spec.rb
@@ -73,6 +73,25 @@ def mock_column(name, type, options={})
+ it "should get schema info even if the primary key is array, if using composite_primary_keys" do
+ klass = mock_class(:users, nil, [
+ [mock_column(:a_id, :integer), mock_column(:b_id, :integer)],
+ mock_column(:name, :string, :limit => 50)
+ ])
+ AnnotateModels.get_schema_info(klass, "Schema Info").should eql(<<-EOS)
+# Schema Info
+# Table name: users
+# a_id :integer not null
+# b_id :integer not null
+# name :string(50) not null
+ end
it "should get schema info as RDoc" do
klass = mock_class(:users, :id, [
mock_column(:id, :integer),
Something went wrong with that request. Please try again.