Closed
Description
Since v3.1.0, we got incorrect default values by annotate_models.
It is a part of our diff between v3.0.3 and v3.1.0.
-# comments_count :integer default(0), not null
-# comment_users_unique_count :integer default(0), not null
-# coediting :boolean default(FALSE), not null
+# comments_count :integer default("0"), not null
+# comment_users_unique_count :integer default("0"), not null
+# coediting :boolean default("false"), not null
And a part of schema.rb for the columns definitions.
t.integer "comments_count", default: 0, null: false
t.integer "comment_users_unique_count", default: 0, null: false
t.boolean "coediting", default: false, null: false
I guess it depends on RDBMS because the spec is not wrong.
We use PostgreSQL.
Probably this pull request is related. #677
Commands
$ bin/rake annotate_models
And I investigated the ActiveRecord::ConnectionAdapters::PostgreSQLColumn#default
returned value, which is used by #677, and klass.column_defaults[column.name]
, which was used previously.
$ bin/rails console
> klass.columns.find{|x| x.name == 'comments_count'}.default
=> "0"
> klass.column_defaults["comments_count"]
=> 0
Version
- annotate version: v3.1.0
- rails version: 5.2.4.1
- ruby version: 2.6.4