On Tue, Jul 17, 2012 at 9:42 PM, Ben Woosley <[email protected]> wrote: > Agree that propagating the data-type directly from the database is ideal. > That's what's being done in the 2 places I found where type-casting was > being performed: > > For attributes drawn from schema columns (see #read_attribute @columns_hash) > Under Postgres, when attributes have associated OID information i.e. > > In fact as I recall the example I posted above works under Postgres on > master, thanks to OID support, but not on sqlite or (presumably) mysql.
On SQLite, computed columns are unlikely to ever return datetime values, due to SQLite's type system not supporting them. MySQL provides type id information similar to PostgreSQL. For the mysql adapter, ActiveRecord master already uses this information (https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb#L228). For the mysql2 adapter, the typecasting is done internally, so ActiveRecord doesn't need to worry about it. In terms of your patch to add cast! and cast methods, the only database I see that helping is SQLite. All other databases in common use support real timestamp types and should not need manually overrides at the ruby level. Jeremy -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
