class Babik::Selection::Operation::Month

Month date operation

Public Class Methods

new(field, operator, value) click to toggle source
# File lib/babik/queryset/lib/selection/operation/date.rb, line 69
def initialize(field, operator, value)
  value = format('%02d', value) if db_engine == 'sqlite3'
  super(field, operator, value)
end

Public Instance Methods

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