Module: Hoardable::ArelCrud

Defined in:
lib/hoardable/arel_crud.rb

Overview

Monkey-patches an internal Arel method to ensure that bulk UPDATE’s always operate directly on the root table by injecting the ONLY keyword.

Instance Method Summary collapse

Instance Method Details

#compile_update(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/hoardable/arel_crud.rb', line 5

def compile_update(*args)
  um = super(*args)

  if source.left.instance_variable_get(:@klass).in?(Hoardable::REGISTRY)
    return um.table(Arel.sql("ONLY #{source.left.name}"))
  end

  um
end