Sha256: 787c39e2471e3836f1f32c68c52bdbe7657c011b4d4f131123fbc2902bd29a59

Contents?: true

Size: 1.6 KB

Versions: 83

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 4.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 4.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 4.0.0. Please
switch to `compile_delete`
        eowarn
      end
      @engine.connection.delete compile_delete.to_sql, 'AREL'
    end
  end
end

Version data entries

83 entries across 65 versions & 13 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/arel-3.0.3/lib/arel/crud.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/crud.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/arel-3.0.2/lib/arel/crud.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/crud.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/crud.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/arel-3.0.3/lib/arel/crud.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/arel-3.0.3/lib/arel/crud.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/arel-3.0.3/lib/arel/crud.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/crud.rb
arel-3.0.3 lib/arel/crud.rb
swipe-rails-0.0.5 vendor/bundle/gems/arel-3.0.2/lib/arel/crud.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/crud.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/crud.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/crud.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/crud.rb
challah-1.0.0.beta3 vendor/bundle/gems/arel-3.0.2/lib/arel/crud.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/crud.rb
challah-1.0.0.beta2 vendor/bundle/gems/arel-3.0.2/lib/arel/crud.rb
challah-1.0.0.beta vendor/bundle/gems/arel-3.0.2/lib/arel/crud.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/arel-3.0.2/lib/arel/crud.rb