1

I want to update all sql statements for the queries generated for sql_for_insert, query, execute and update_sql for postgres. I'm using rails 3.2.17. Main aim is to change the column names to lower case. I tried to define a class "class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter" in initializers, methods are called over there, but I can't call super as my class isn't extended from any other class.

1 Answer 1

1

I got an alternate solution to just update the column names at one single location. I made a module and included it in Arel:Attributes:Attribute, this module converts the column names into lower case. This code is still under testing for me and not into production. But this seemed to have solved my problem.

module ArelAttributeWrapper
  def self.included base
    @actualname = nil
    base.class_eval do
      def initialize(*args)
        super(*args)
        @actualname = args[1]
      end
      def name=(value)
        @actualname = value.downcase
      end

      def name
        @actualname.downcase
      end
    end
  end
end

Arel::Attributes::Attribute.send(:include, ArelAttributeWrapper)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.