mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
13 lines
433 B
Ruby
13 lines
433 B
Ruby
module RDBMSFunctions
|
|
def rdbms_date_add(source, unit, amount)
|
|
adapter_type = ActiveRecord::Base.connection.adapter_name.downcase.to_sym
|
|
case adapter_type
|
|
when :mysql, :mysql2
|
|
"DATE_ADD(`#{source}`, INTERVAL #{amount} #{unit})"
|
|
when :postgresql
|
|
"(#{source} + INTERVAL '#{amount} #{unit}')"
|
|
else
|
|
raise NotImplementedError, "Unknown adapter type '#{adapter_type}'"
|
|
end
|
|
end
|
|
end
|