sdsykes / slim_scrooge

SlimScrooge heavily optimises your database interactions
313 stars 25 forks source link

read_attribute doesnt work with Rails 3.2.15 #29

Open bhushangahire opened 9 years ago

bhushangahire commented 9 years ago

I have a code in model to update column to have custom text appended.

def name read_attribute(:name) + " (N)" if read_attribute(:name).present? end

Its not working with this plugin. Is it bcas its not compatible with rails 3.2 or I can fix it with minor code change?

ActiveRecord::StatementInvalid - Mysql2::Error: Unknown column '174' in 'where clause': SELECT markets.name,markets.division_id,markets.active,markets.creator_id,markets.updater_id,markets.created_at,markets.updated_at,markets.market_type,markets.short_name,markets.time_zone_id,markets.region_id,markets.country_id,markets.state_id,markets.id FROM markets WHERE id IN (174,197): activerecord (3.2.15) lib/active_record/connection_adapters/abstract_adapter.rb:285:in rescue in log' activerecord (3.2.15) lib/active_record/connection_adapters/abstract_adapter.rb:280:inlog' activerecord (3.2.15) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in execute' activerecord (3.2.15) lib/active_record/connection_adapters/mysql2_adapter.rb:213:inexecute' activerecord (3.2.15) lib/active_record/connection_adapters/mysql2_adapter.rb:217:in exec_query' activerecord (3.2.15) lib/active_record/connection_adapters/mysql2_adapter.rb:226:inselect' slim_scrooge (1.0.14) lib/slim_scrooge/result_set.rb:29:in reload!' slim_scrooge (1.0.14) lib/slim_scrooge/monitored_hash.rb:32:innew_column_access' slim_scrooge (1.0.14) lib/slim_scrooge/monitored_hash.rb:19:in `block in []'

sdsykes commented 9 years ago

Clearly something wrong with the sql statement - this isn't maintained any longer, but please feel free to fork / fix.

bhushangahire commented 9 years ago

SQl statement is built wrong as its putting 174 id in quote like '174' any pointers where to update the SQL generation would be good I can update the code then.