huginn/lib/rdbms_functions.rb

14 lines
409 B
Ruby
Raw Normal View History

module RDBMSFunctions
def rdbms_date_add(source, unit, amount)
adapter_type = connection.adapter_name.downcase.to_sym
case adapter_type
when :mysql
2014-03-11 23:05:10 +01:00
"DATE_ADD(`#{source}`, INTERVAL #{amount} #{unit})"
when :postgresql
"(#{source} + INTERVAL '#{amount} #{unit}')"
else
raise NotImplementedError, "Unknown adapter type '#{adapter_type}'"
end
end
end