Sha256: 35a4e4b1b6816b89c7806e0183dbd4417704e1051aafe4e72a34fc1d4522e677

Contents?: true

Size: 1.39 KB

Versions: 12

Compression:

Stored size: 1.39 KB

Contents

module ThinkingSphinx
  class AbstractAdapter
    def initialize(model)
      @model = model
    end
    
    def setup
      # Deliberately blank - subclasses should do something though. Well, if
      # they need to.
    end
      
    def self.detect(model)
      case model.connection.class.name
      when "ActiveRecord::ConnectionAdapters::MysqlAdapter",
           "ActiveRecord::ConnectionAdapters::MysqlplusAdapter"
        ThinkingSphinx::MysqlAdapter.new model
      when "ActiveRecord::ConnectionAdapters::PostgreSQLAdapter"
        ThinkingSphinx::PostgreSQLAdapter.new model
      when "ActiveRecord::ConnectionAdapters::JdbcAdapter"
        if model.connection.config[:adapter] == "jdbcmysql"
          ThinkingSphinx::MysqlAdapter.new model
        elsif model.connection.config[:adapter] == "jdbcpostgresql"
          ThinkingSphinx::PostgreSQLAdapter.new model
        else
          raise "Invalid Database Adapter: Sphinx only supports MySQL and PostgreSQL"
        end
      else
        raise "Invalid Database Adapter: Sphinx only supports MySQL and PostgreSQL, not #{model.connection.class.name}"
      end
    end
    
    def quote_with_table(column)
      "#{@model.quoted_table_name}.#{@model.connection.quote_column_name(column)}"
    end
    
    def bigint_pattern
      /bigint/i
    end
    
    protected
    
    def connection
      @connection ||= @model.connection
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
joshcutler-thinking-sphinx-1.3.18 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-allen-1.3.18.4 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-allen-1.3.18.3 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-allen-1.3.18.2 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-2.0.0.rc1 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-allen-1.3.18.1 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-allen-1.3.18 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-1.3.18 lib/thinking_sphinx/adapters/abstract_adapter.rb
josh_cutler-thinking-sphinx-1.3.17 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-1.3.17 lib/thinking_sphinx/adapters/abstract_adapter.rb
warp-thinking-sphinx-1.3.16 lib/thinking_sphinx/adapters/abstract_adapter.rb
thinking-sphinx-1.3.16 lib/thinking_sphinx/adapters/abstract_adapter.rb