Sha256: 2035b9b9456199d537704305e2753c17e67523eb4ddf5867266918f506f089cd

Contents?: true

Size: 1.57 KB

Versions: 79

Compression:

Stored size: 1.57 KB

Contents

module Arel
  module Visitors
    module ArJdbcCompat

      protected

      if ToSql.instance_method('visit').arity == 1
        def do_visit(x, a); visit(x); end # a = nil
      else # > AREL 4.0
        def do_visit(x, a); visit(x, a); end
      end

      if ToSql.instance_method('visit_Arel_Nodes_SelectCore').arity == 1
        def do_visit_select_core(x, a) # a = nil
          visit_Arel_Nodes_SelectCore(x)
        end
      else # > AREL 4.0
        def do_visit_select_core(x, a)
          visit_Arel_Nodes_SelectCore(x, a)
        end
      end

      private

      if ArJdbc::AR42
        if Arel::VERSION < '6.0.2'
          def limit_for(limit_or_node)
            if limit_or_node.respond_to?(:expr)
              expr = limit_or_node.expr
              # NOTE(uwe): Different behavior for Arel 6.0.0 and 6.0.2
              expr.respond_to?(:value) ? expr.value.to_i : expr.to_i
            else
              limit_or_node
            end
          end
        else
          def limit_for(limit_or_node)
            limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
          end
        end
      else
        def limit_for(limit_or_node)
          limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
        end
      end
      module_function :limit_for

      def node_value(node)
        return nil unless node
        case expr = node.expr
          when NilClass then nil
          when Numeric then expr
          when Arel::Nodes::Unary then expr.expr
        end
      end

    end
    ToSql.send(:include, ArJdbcCompat)
  end
end

Version data entries

79 entries across 79 versions & 3 rubygems

Version Path
activerecord-jdbc-alt-adapter-61.3.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-61.3-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-60.3.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-61.2.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-70.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-70.0.pre-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-61.2-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-60.2.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-61.1.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-61.1-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-60.4-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-52.8-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-61.0.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-60.1.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-52.6.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-51.7.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-alt-adapter-50.7.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-61.0-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-60.3-java lib/arel/visitors/compat.rb
activerecord-jdbc-adapter-52.7-java lib/arel/visitors/compat.rb