Sha256: 8e263e13231e421c01d145c7fdb5b5b101bbc1f6f5e9d16168836c8415ab9493

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true
module Arel
  ###
  # FIXME hopefully we can remove this
  module Crud
    def compile_update values, pk
      um = UpdateManager.new

      if Nodes::SqlLiteral === values
        relation = @ctx.from
      else
        relation = values.first.first.relation
      end
      um.key = pk
      um.table relation
      um.set values
      um.take @ast.limit.expr if @ast.limit
      um.order(*@ast.orders)
      um.wheres = @ctx.wheres
      um
    end

    def compile_insert values
      im = create_insert
      im.insert values
      im
    end

    def create_insert
      InsertManager.new
    end

    def compile_delete
      dm = DeleteManager.new
      dm.take @ast.limit.expr if @ast.limit
      dm.wheres = @ctx.wheres
      dm.from @ctx.froms
      dm
    end

  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
spiral_form-0.1.1 vendor/bundle/gems/arel-9.0.0/lib/arel/crud.rb
spiral_form-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/crud.rb
nullifyable-0.1.0 vendor/bundle/gems/arel-9.0.0/lib/arel/crud.rb
arel-9.0.0 lib/arel/crud.rb
arel-8.0.0 lib/arel/crud.rb