Sha256: 9ce4df1ae24fe370d6709d7d80dfa85d596be8f6b7037b780b95eef00f1defbb

Contents?: true

Size: 855 Bytes

Versions: 5

Compression:

Stored size: 855 Bytes

Contents

module Clevic
  # Provide some SQL dialect differences that aren't in ActiveRecord. Including
  # class must respond to entity_class.
  module SqlDialects
    def adapter_name
      connection.adapter_name
    end
    
    def connection
      entity_class.connection
    end
    
    # return a string containing the correct
    # boolean value depending on the DB adapter
    # because Postgres wants real true and false in complex statements, not 't' and 'f'
    def sql_boolean( value )
      case adapter_name
        when 'PostgreSQL'
          value ? 'true' : 'false'
        else
          value ? connection.quoted_true : connection.quoted_false
      end
    end
    
    # return a case-insensitive like operator
    def like_operator
      case adapter_name
        when 'PostgreSQL'; 'ilike'
        else; 'like'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
clevic-0.13.0.b3 lib/clevic/sql_dialects.rb
clevic-0.13.0.b2 lib/clevic/sql_dialects.rb
clevic-0.13.0.b1 lib/clevic/sql_dialects.rb
clevic-0.12.0 lib/clevic/sql_dialects.rb
clevic-0.11.1 lib/clevic/sql_dialects.rb