I'm moving a legacy app from MS-SQL to Postgres which uses Rails to access the data.
The columns in MS-SQL are capitalised, and while using activerecord-sql-server-adapter, they are read like this:
var something = my_model.SomeAttribute
Even though it is constant, it doesn't appear to matter since the app only reads data from the MSSQL db.
The issue I'm having now is after moving to postgres, it converts all column names etc to lowercase (as SQL is not meant to be case-sensitive). Now when I try to access SomeAttribute
on my model, it raises an ActiveModel::MissingAttributeError
since it's now lowercase.
Some examples of the symptom:
p.SomeAttribute
=> ActiveModel::MissingAttributeError: missing attribute: SomeAttribute
p.read_attribute(:SomeAttribute)
=> nil
p.has_attribute?(:SomeAttribute)
=> false
p.read_attribute(:someattribute)
=> 'expected value'
Is there some way I can get ActiveRecord/ActiveModel to convert attribute names to lowercase before attempting to retrieve them?