2017-02-13 13:58:58 -05:00
|
|
|
# frozen_string_literal: true
|
2018-02-24 01:45:50 -05:00
|
|
|
|
2018-02-24 02:41:47 -05:00
|
|
|
module Arel # :nodoc: all
|
2010-08-16 17:56:56 -04:00
|
|
|
###
|
|
|
|
# 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
|
2010-08-16 17:56:56 -04:00
|
|
|
im.insert values
|
2010-12-02 17:01:08 -05:00
|
|
|
im
|
|
|
|
end
|
|
|
|
|
2011-03-22 00:23:48 -04:00
|
|
|
def create_insert
|
2014-11-29 19:22:17 -05:00
|
|
|
InsertManager.new
|
2011-03-22 00:23:48 -04:00
|
|
|
end
|
|
|
|
|
2021-10-18 18:28:48 -04:00
|
|
|
def compile_update(
|
|
|
|
values,
|
|
|
|
key = nil,
|
|
|
|
having_clause = nil,
|
|
|
|
group_values_columns = []
|
|
|
|
)
|
2021-03-15 04:15:35 -04:00
|
|
|
um = UpdateManager.new(source)
|
|
|
|
um.set(values)
|
|
|
|
um.take(limit)
|
|
|
|
um.offset(offset)
|
|
|
|
um.order(*orders)
|
|
|
|
um.wheres = constraints
|
|
|
|
um.key = key
|
2021-10-18 18:28:48 -04:00
|
|
|
|
|
|
|
um.group(group_values_columns) unless group_values_columns.empty?
|
|
|
|
um.having(having_clause) unless having_clause.nil?
|
2021-03-15 04:15:35 -04:00
|
|
|
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
|
2010-12-02 18:45:00 -05:00
|
|
|
dm
|
|
|
|
end
|
2010-08-16 17:56:56 -04:00
|
|
|
end
|
|
|
|
end
|