1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/crud.rb

47 lines
928 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-02-24 01:45:50 -05:00
2018-02-24 02:41:47 -05:00
module Arel # :nodoc: all
###
# FIXME hopefully we can remove this
module Crud
2018-02-24 01:45:50 -05:00
def compile_insert(values)
2011-03-22 00:23:48 -04:00
im = create_insert
im.insert values
2010-12-02 17:01:08 -05:00
im
end
2011-03-22 00:23:48 -04:00
def create_insert
InsertManager.new
2011-03-22 00:23:48 -04:00
end
def compile_update(
values,
key = nil,
having_clause = nil,
group_values_columns = []
)
um = UpdateManager.new(source)
um.set(values)
um.take(limit)
um.offset(offset)
um.order(*orders)
um.wheres = constraints
um.key = key
um.group(group_values_columns) unless group_values_columns.empty?
um.having(having_clause) unless having_clause.nil?
um
end
def compile_delete(key = nil)
dm = DeleteManager.new(source)
dm.take(limit)
dm.offset(offset)
dm.order(*orders)
dm.wheres = constraints
dm.key = key
dm
end
end
end