Sha256: d326ad9e0002ffd71600ea3fd7da67fca57bd10e5af11facb10ad3d029dd25cc

Contents?: true

Size: 1.02 KB

Versions: 41

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Arel # :nodoc: all
  ###
  # Methods for creating various nodes
  module FactoryMethods
    def create_true
      Arel::Nodes::True.new
    end

    def create_false
      Arel::Nodes::False.new
    end

    def create_table_alias(relation, name)
      Nodes::TableAlias.new(relation, name)
    end

    def create_join(to, constraint = nil, klass = Nodes::InnerJoin)
      klass.new(to, constraint)
    end

    def create_string_join(to)
      create_join to, nil, Nodes::StringJoin
    end

    def create_and(clauses)
      Nodes::And.new clauses
    end

    def create_on(expr)
      Nodes::On.new expr
    end

    def grouping(expr)
      Nodes::Grouping.new expr
    end

    ###
    # Create a LOWER() function
    def lower(column)
      Nodes::NamedFunction.new "LOWER", [Nodes.build_quoted(column)]
    end

    def coalesce(*exprs)
      Nodes::NamedFunction.new "COALESCE", exprs
    end

    def cast(name, type)
      Nodes::NamedFunction.new "CAST", [name.as(type)]
    end
  end
end

Version data entries

41 entries across 41 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activerecord-7.1.3.4/lib/arel/factory_methods.rb
activerecord-8.0.1 lib/arel/factory_methods.rb
activerecord-8.0.0.1 lib/arel/factory_methods.rb
activerecord-7.2.2.1 lib/arel/factory_methods.rb
activerecord-7.1.5.1 lib/arel/factory_methods.rb
activerecord-8.0.0 lib/arel/factory_methods.rb
activerecord-7.2.2 lib/arel/factory_methods.rb
activerecord-7.1.5 lib/arel/factory_methods.rb
activerecord-8.0.0.rc2 lib/arel/factory_methods.rb
activerecord-7.2.1.2 lib/arel/factory_methods.rb
activerecord-7.1.4.2 lib/arel/factory_methods.rb
activerecord-8.0.0.rc1 lib/arel/factory_methods.rb
activerecord-7.2.1.1 lib/arel/factory_methods.rb
activerecord-7.1.4.1 lib/arel/factory_methods.rb
activerecord-8.0.0.beta1 lib/arel/factory_methods.rb
omg-activerecord-8.0.0.alpha9 lib/arel/factory_methods.rb
omg-activerecord-8.0.0.alpha8 lib/arel/factory_methods.rb
omg-activerecord-8.0.0.alpha7 lib/arel/factory_methods.rb
omg-activerecord-8.0.0.alpha4 lib/arel/factory_methods.rb
omg-activerecord-8.0.0.alpha3 lib/arel/factory_methods.rb