Sha256: f31f373c0a80822b5aa9e5515bc7beb3442fed009eb7f641f87ed6d64af63218

Contents?: true

Size: 1.85 KB

Versions: 6

Compression:

Stored size: 1.85 KB

Contents

module Searchgasm
  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})"
        end
        
        def minute_sql(column_name)
          "strftime('%M', #{column_name})"
        end
        
        def hour_sql(column_name)
          "strftime('%H', #{column_name})"
        end
        
        def day_of_week_sql(column_name)
          "strftime('%w', #{column_name})"
        end
        
        def day_of_month_sql(column_name)
          "strftime('%d', #{column_name})"
        end
        
        def day_of_year_sql(column_name)
          "strftime('%j', #{column_name})"
        end
        
        def week_sql(column_name)
          "strftime('%W', #{column_name})"
        end
        
        def month_sql(column_name)
          "strftime('%m', #{column_name})"
        end
        
        def year_sql(column_name)
          "strftime('%Y', #{column_name})"
        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, Searchgasm::ActiveRecord::ConnectionAdapters::SQLiteAdapter)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
searchgasm-1.5.2 lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb
searchgasm-1.5.3 lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb
searchgasm-1.5.1 lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb
searchgasm-1.5.0 lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb
searchgasm-1.4.1 lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb
searchgasm-1.4.0 lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb