Module: Arel::Crud

Included in:
SelectManager, Table
Defined in:
lib/arel/crud.rb

Overview

FIXME hopefully we can remove this

Instance Method Summary collapse

Instance Method Details

#compile_deleteObject



55
56
57
58
59
60
# File 'lib/arel/crud.rb', line 55

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

#compile_insert(values) ⇒ Object



34
35
36
37
38
# File 'lib/arel/crud.rb', line 34

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

#compile_update(values) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/arel/crud.rb', line 5

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

#create_insertObject



40
41
42
# File 'lib/arel/crud.rb', line 40

def create_insert
  InsertManager.new @engine
end

#deleteObject



62
63
64
65
66
67
68
69
70
# File 'lib/arel/crud.rb', line 62

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

#insert(values) ⇒ Object

FIXME: this method should go away



45
46
47
48
49
50
51
52
53
# File 'lib/arel/crud.rb', line 45

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

#update(values) ⇒ Object

FIXME: this method should go away



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/arel/crud.rb', line 22

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