Sha256: f83cf4adb15b9b4da8de17080b98b3047e8a27de0f7d2be54f84bc095475268d

Contents?: true

Size: 781 Bytes

Versions: 129

Compression:

Stored size: 781 Bytes

Contents

module Arel
  class InsertManager < Arel::TreeManager
    def initialize engine
      super
      @ast = Nodes::InsertStatement.new
    end

    def into table
      @ast.relation = table
      self
    end

    def columns; @ast.columns end
    def values= val; @ast.values = val; end

    def insert fields
      return if fields.empty?

      if String === fields
        @ast.values = SqlLiteral.new(fields)
      else
        @ast.relation ||= fields.first.first.relation

        values = []

        fields.each do |column, value|
          @ast.columns << column
          values << value
        end
        @ast.values = create_values values, @ast.columns
      end
    end

    def create_values values, columns
      Nodes::Values.new values, columns
    end
  end
end

Version data entries

129 entries across 111 versions & 15 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/arel-3.0.3/lib/arel/insert_manager.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/lib/arel/insert_manager.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/lib/arel/insert_manager.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/lib/arel/insert_manager.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/insert_manager.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/arel-3.0.2/lib/arel/insert_manager.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/lib/arel/insert_manager.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/lib/arel/insert_manager.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/lib/arel/insert_manager.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/arel-3.0.3/lib/arel/insert_manager.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/lib/arel/insert_manager.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/arel-3.0.3/lib/arel/insert_manager.rb
arel-5.0.1.20140414130214 lib/arel/insert_manager.rb
arel-4.0.2 lib/arel/insert_manager.rb
arel-5.0.0 lib/arel/insert_manager.rb
arel-3.0.3 lib/arel/insert_manager.rb
arel-4.0.1 lib/arel/insert_manager.rb
challah-1.0.0 vendor/bundle/gems/arel-4.0.0/lib/arel/insert_manager.rb
swipe-rails-0.0.5 vendor/bundle/gems/arel-3.0.2/lib/arel/insert_manager.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/insert_manager.rb