The PostgreSQL type "interval" can actually happen to have a precision. (See http://www.postgresql.org/docs/9.1/static/datatype-datetime.html )Thus "interval(6)" is a type as legal as "interval".
However, the current ActiveRecord implementation maps "interval" to :string (which is correct, as there is no Ruby data type which better matches the postgresql interval data type without data loss), but it maps "interval(6)" to :integer.
There are actually 3 bugs.
Update: changed title to not mess up with Github, old title was:
ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new(nil,nil).send(:simplified_type,"interval(6)").should == ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new(nil,nil).send(:simplified_type,"interval")
Would you mind changing the issue title to be a bit more descriptive please? Thanks.
I'll have a look at this one.
postgres, map scaled intervals to string datatype (#7518)
I fixed the bug. Regarding point 2 and 3 you mentioned. Currently all columns have the same superclass, which has the described behavior. This is not really postgres related. In my opinion it could be beneficiary to have the whole #simplified_type method in the postgres adapter. This would allow us to map the datatyps more cleanly and we could raise errors when something is not supported.
@rafaelfranca Is there a specific reason why #simplified_type delegates to the superclass? I think share code in the mapping of datatypes over specific vendors is more a drawback than an advantage.
@senny I don't think there is a particular reason. If it makes sense to push all the code down to the subclass, then we should do it. (I've had the same question myself, so I'm glad you brought it up)
@tenderlove I'll work out a PR with all the code pushed into the subclass and proper error handling. We can then discuss the advantages and disadvantages in that PR.
Closed by #7545, thanks!
@senny sounds good. Thank you!