Hi Koz, Your proposal looks sound to me, however I think it only goes half way. In my view there are two main issues with active record:
* The mixing of Ruby objects and raw database values (strings) in the attributes hash table * The lack of proper column objects For more details, I wrote up some of my thoughts at http://cfis.savagexi.com/articles/2007/08/11/making-rails-better-fixing-architecture-flaws-in-active-record. But in a nutshell, in think much of the grunginess of ActiveRecord could be eliminated by introducing a column object per data type. So FloatColumn, StringColumn, BooleanColumn, etc. Each column would provide an api for serializing/deserializing Ruby objects to and from the database's string representation. That would clean up ActiveRecord by removing a large number of case statements in the connection adapters and schema_definitions.rb. And more importantly, it would make it much easier for developers to add their own custom data types when needed. To see what I mean, try to add your own custom data type (say Postgresql PostGIS data types) to ActiveRecord and see how difficult it is (without of course modifying ActiveRecord itself). Adding a column type directly influences your proposal, because the serialization methods would be used to convert to and from the attributes hash (sounds like you are using that for the raw value from the database) and the attributes_cache hash (which stores the serialized form as a Ruby object). So something like: attributes_cache['foo'] = self.columns['foo'].serialize(attributes['foo']) And of course vice-versa. Last, it would be really useful to add a "changed" flag for each field in each record. Then when ActiveRecord creates an UPDATE query it would only modify the values that actually changed. Right now, ActiveRecord updates all columns, which turns out to be a pain because it has a tendency to botch values for columns that have a default expression or have a type that it doesn't know about (postgis fields for example). So just my two cents - happy to discuss more if these seem like useful ideas. Charlie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
