Sha256: bc542bc3314dc63d9ba53ed6df43687382e90320b5392746291efd28393b98bf

Contents?: true

Size: 1.6 KB

Versions: 37

Compression:

Stored size: 1.6 KB

Contents

module Arel
  ###
  # FIXME hopefully we can remove this
  module Crud
    def compile_update values
      um = UpdateManager.new @engine

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

    # FIXME: this method should go away
    def update values
      if $VERBOSE
        warn <<-eowarn
update (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please
switch to `compile_update`
        eowarn
      end

      um = compile_update values
      @engine.connection.update um.to_sql, 'AREL'
    end

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

    def create_insert
      InsertManager.new @engine
    end

    # FIXME: this method should go away
    def insert values
      if $VERBOSE
        warn <<-eowarn
insert (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please
switch to `compile_insert`
        eowarn
      end
      @engine.connection.insert compile_insert(values).to_sql
    end

    def compile_delete
      dm = DeleteManager.new @engine
      dm.wheres = @ctx.wheres
      dm.from @ctx.froms
      dm
    end

    def delete
      if $VERBOSE
        warn <<-eowarn
delete (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please
switch to `compile_delete`
        eowarn
      end
      @engine.connection.delete compile_delete.to_sql, 'AREL'
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.6.0 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.5.4 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.5.3 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.5.2 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
arel-2.2.3 lib/arel/crud.rb
arel-2.2.2 lib/arel/crud.rb
dirty_history-0.5.1 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/arel-2.2.1/lib/arel/crud.rb