class Babik::Selection::Operation::Quarter

Quarter where the date is operation

Public Instance Methods

sql_function() click to toggle source
# File lib/babik/queryset/lib/selection/operation/date.rb, line 58
def sql_function
  dbms_adapter = db_engine
  return 'QUARTER(#field)' if dbms_adapter == 'mysql2'
  return 'EXTRACT(QUARTER FROM #field)' if dbms_adapter == 'postgresql'
  return '(CAST(strftime(\'%m\', #field) AS INTEGER) + 2) / 3' if dbms_adapter == 'sqlite3'
  raise NotImplementedError, "#{self.class} lookup not implemented for #{dbms_adapter}"
end