Sha256: 03beaee6e0027477beb1b2df3e44ffcf26e9d985c1c644f5f20080bcd7fa094a

Contents?: true

Size: 1.91 KB

Versions: 9

Compression:

Stored size: 1.91 KB

Contents

module Searchlogic
  module ActiveRecord
    module ConnectionAdapters
      module SQLiteAdapter
        # Date functions
        def microseconds_sql(column_name)
          "((strftime('%f', #{column_name}) % 1) * 1000000)"
        end
        
        def milliseconds_sql(column_name)
          "((strftime('%f', #{column_name}) % 1) * 1000)"
        end
        
        def second_sql(column_name)
          "(strftime('%S', #{column_name}) * 1)"
        end
        
        def minute_sql(column_name)
          "(strftime('%M', #{column_name}) * 1)"
        end
        
        def hour_sql(column_name)
          "(strftime('%H', #{column_name}) * 1)"
        end
        
        def day_of_week_sql(column_name)
          "(strftime('%w', #{column_name}) * 1)"
        end
        
        def day_of_month_sql(column_name)
          "(strftime('%d', #{column_name}) * 1)"
        end
        
        def day_of_year_sql(column_name)
          "(strftime('%j', #{column_name}) * 1)"
        end
        
        def week_sql(column_name)
          "(strftime('%W', #{column_name}) * 1)"
        end
        
        def month_sql(column_name)
          "(strftime('%m', #{column_name}) * 1)"
        end
        
        def year_sql(column_name)
          "(strftime('%Y', #{column_name}) * 1)"
        end
        
        # String functions
        def lower_sql(column_name)
          "lower(#{column_name})"
        end
        
        def ltrim_sql(column_name)
          "ltrim(#{column_name})"
        end
        
        def rtrim_sql(column_name)
          "rtrim(#{column_name})"
        end
        
        def trim_sql(column_name)
          "trim(#{column_name})"
        end
        
        def upper_sql(column_name)
          "upper(#{column_name})"
        end
      end
    end
  end
end

::ActiveRecord::ConnectionAdapters::SQLiteAdapter.send(:include, Searchlogic::ActiveRecord::ConnectionAdapters::SQLiteAdapter)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
searchlogic-1.5.7 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.5.10 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.6.1 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.5.6 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.5.8 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.6.0 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.5.9 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.5.4 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
searchlogic-1.6.2 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb