<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -67,7 +67,6 @@ end
 
 # Load all lib files
 require 'scoped_search/definition'
-require 'scoped_search/adapters'
 require 'scoped_search/query_language'
 require 'scoped_search/query_builder'
 </diff>
      <filename>lib/scoped_search.rb</filename>
    </modified>
    <modified>
      <diff>@@ -106,7 +106,6 @@ module ScopedSearch
       @fields        = {}
       @unique_fields = []
 
-      setup_adapter!        unless klass.connection.nil?
       register_named_scope! unless klass.respond_to?(:search_for)
     end
 
@@ -118,7 +117,7 @@ module ScopedSearch
       column_types  = []
       column_types += [:string, :text]                      if [nil, :like, :unlike, :ne, :eq].include?(operator)
       column_types += [:integer, :double, :float, :decimal] if value =~ NUMERICAL_REGXP
-      column_types += [:datetime, :date, :timestamp]        if ScopedSearch::QueryBuilder.parse_temporal(value)
+      column_types += [:datetime, :date, :timestamp]        if (DateTime.parse(value) rescue nil)
 
       default_fields.select { |field| column_types.include?(field.type) }
     end
@@ -142,10 +141,5 @@ module ScopedSearch
     def register_named_scope! # :nodoc
       @klass.named_scope(:search_for, lambda { |*args| ScopedSearch::QueryBuilder.build_query(args[1] || self, args[0]) })
     end
-
-    # Installs the database adapter based on the current database connection.
-    def setup_adapter!
-      ScopedSearch::Adapter.setup(@klass.connection)
-    end
   end
 end</diff>
      <filename>lib/scoped_search/definition.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,16 +15,25 @@ module ScopedSearch
     # query. It will return an ampty hash if the search query is empty, in which case
     # the scope call will simply return all records.
     def self.build_query(definition, query)
+      query_builder_class = self.class_for(definition)
       if query.kind_of?(ScopedSearch::QueryLanguage::AST::Node)
-        return self.new(definition, query).build_find_params
+        return query_builder_class.new(definition, query).build_find_params
       elsif query.kind_of?(String)
-        return self.new(definition, ScopedSearch::QueryLanguage::Compiler.parse(query)).build_find_params
+        return query_builder_class.new(definition, ScopedSearch::QueryLanguage::Compiler.parse(query)).build_find_params
       elsif query.nil?
         return { }
       else
         raise &quot;Unsupported query object: #{query.inspect}!&quot;
       end
     end
+    
+    # Loads the QueryBuilder class for the connection of the given definition.
+    # If no specific adapter is found, the default QueryBuilder class is returned.
+    def self.class_for(definition)
+      self.const_get(definition.klass.connection.class.name.split('::').last)
+    rescue
+      self
+    end
 
     # Initializes the instance by setting the relevant parameters
     def initialize(definition, ast)
@@ -38,7 +47,7 @@ module ScopedSearch
       includes   = []
 
       # Build SQL WHERE clause using the AST
-      sql = @ast.to_sql(definition) do |notification, value|
+      sql = @ast.to_sql(self, definition) do |notification, value|
 
         # Handle the notifications encountered during the SQL generation:
         # Store the parameters, includes, etc so that they can be added to
@@ -54,19 +63,19 @@ module ScopedSearch
       find_attributes = {}
       find_attributes[:conditions] = [sql] + parameters unless sql.nil?
       find_attributes[:include]    = includes.uniq      unless includes.empty?
-      # p find_attributes # Uncomment for debugging
+      find_attributes # Uncomment for debugging
       return find_attributes
     end
 
     # A hash that maps the operators of the query language with the corresponding SQL operator.
     SQL_OPERATORS = { :eq =&gt;'=',  :ne =&gt; '&lt;&gt;', :like =&gt; 'LIKE', :unlike =&gt; 'NOT LIKE',
                       :gt =&gt; '&gt;', :lt =&gt;'&lt;',   :lte =&gt; '&lt;=',    :gte =&gt; '&gt;=' }
-
+    
     # Return the SQL operator to use given an operator symbol and field definition.
     #
     # By default, it will simply look up the correct SQL operator in the SQL_OPERATORS
     # hash, but this can be overrided by a database adapter.
-    def self.sql_operator(operator, field)
+    def sql_operator(operator, field)
       SQL_OPERATORS[operator]
     end
 
@@ -81,7 +90,7 @@ module ScopedSearch
     # &lt;tt&gt;field&lt;/tt&gt;:: The field to test.
     # &lt;tt&gt;operator&lt;/tt&gt;:: The operator used for comparison.
     # &lt;tt&gt;value&lt;/tt&gt;:: The value to compare the field with.
-    def self.datetime_test(field, operator, value, &amp;block) # :yields: finder_option_type, value
+    def datetime_test(field, operator, value, &amp;block) # :yields: finder_option_type, value
 
       # Parse the value as a date/time and ignore invalid timestamps
       timestamp = parse_temporal(value)
@@ -118,7 +127,7 @@ module ScopedSearch
 
       # Yield the timestamp and return the SQL test
       yield(:parameter, timestamp)
-      &quot;#{field.to_sql(operator, &amp;block)} #{self.sql_operator(operator, field)} ?&quot;
+      &quot;#{field.to_sql(operator, &amp;block)} #{sql_operator(operator, field)} ?&quot;
     end
 
     # Generates a simple SQL test expression, for a field and value using an operator.
@@ -129,7 +138,7 @@ module ScopedSearch
     # &lt;tt&gt;field&lt;/tt&gt;:: The field to test.
     # &lt;tt&gt;operator&lt;/tt&gt;:: The operator used for comparison.
     # &lt;tt&gt;value&lt;/tt&gt;:: The value to compare the field with.
-    def self.sql_test(field, operator, value, &amp;block) # :yields: finder_option_type, value
+    def sql_test(field, operator, value, &amp;block) # :yields: finder_option_type, value
       if [:like, :unlike].include?(operator) &amp;&amp; value !~ /^\%/ &amp;&amp; value !~ /\%$/
         yield(:parameter, &quot;%#{value}%&quot;)
         return &quot;#{field.to_sql(operator, &amp;block)} #{self.sql_operator(operator, field)} ?&quot;
@@ -142,7 +151,7 @@ module ScopedSearch
     end
 
     # Try to parse a string as a datetime.
-    def self.parse_temporal(value)
+    def parse_temporal(value)
       DateTime.parse(value, true) rescue nil
     end
 
@@ -156,7 +165,7 @@ module ScopedSearch
       # This function may yield an :include that should be used in the
       # ActiveRecord::Base#find call, to make sure that the field is avalable
       # for the SQL query.
-      def to_sql(operator = nil, &amp;block) # :yields: finder_option_type, value
+      def to_sql(builder, operator = nil, &amp;block) # :yields: finder_option_type, value
         yield(:include, relation) if relation
         definition.klass.connection.quote_table_name(klass.table_name) + &quot;.&quot; +
             definition.klass.connection.quote_column_name(field)
@@ -168,10 +177,10 @@ module ScopedSearch
 
       # Defines the to_sql method for AST LeadNodes
       module LeafNode
-        def to_sql(definition, &amp;block)
+        def to_sql(builder, definition, &amp;block)
           # Search keywords found without context, just search on all the default fields
           fragments = definition.default_fields_for(value).map do |field|
-            ScopedSearch::QueryBuilder.sql_test(field, field.default_operator, value, &amp;block)
+            builder.sql_test(field, field.default_operator, value, &amp;block)
           end
           &quot;(#{fragments.join(' OR ')})&quot;
         end
@@ -181,52 +190,53 @@ module ScopedSearch
       module OperatorNode
 
         # Returns a NOT(...)  SQL fragment that negates the current AST node's children
-        def to_not_sql(definition, &amp;block)
-          &quot;(NOT(#{rhs.to_sql(definition, &amp;block)}) OR #{rhs.to_sql(definition, &amp;block)} IS NULL)&quot;
+        def to_not_sql(builder, definition, &amp;block)
+          &quot;(NOT(#{rhs.to_sql(builder, definition, &amp;block)}) OR #{rhs.to_sql(builder, definition, &amp;block)} IS NULL)&quot;
         end
 
         # Returns an IS (NOT) NULL SQL fragment
-        def to_null_sql(definition, &amp;block)
+        def to_null_sql(builder, definition, &amp;block)
           field = definition.fields[rhs.value.to_sym]
           raise ScopedSearch::QueryNotSupported, &quot;Field '#{rhs.value}' not recognized for searching!&quot; unless field
 
           case operator
-            when :null    then &quot;#{field.to_sql(&amp;block)} IS NULL&quot;
-            when :notnull then &quot;#{field.to_sql(&amp;block)} IS NOT NULL&quot;
+            when :null    then &quot;#{field.to_sql(builder, &amp;block)} IS NULL&quot;
+            when :notnull then &quot;#{field.to_sql(builder, &amp;block)} IS NOT NULL&quot;
           end
         end
 
         # No explicit field name given, run the operator on all default fields
-        def to_default_fields_sql(definition, &amp;block)
+        def to_default_fields_sql(builder, definition, &amp;block)
           raise ScopedSearch::QueryNotSupported, &quot;Value not a leaf node&quot; unless rhs.kind_of?(ScopedSearch::QueryLanguage::AST::LeafNode)
 
           # Search keywords found without context, just search on all the default fields
           fragments = definition.default_fields_for(rhs.value, operator).map { |field|
-            ScopedSearch::QueryBuilder.sql_test(field, operator, rhs.value, &amp;block) }.compact
+                          builder.sql_test(field, operator, rhs.value, &amp;block) }.compact
+
           fragments.empty? ? nil : &quot;(#{fragments.join(' OR ')})&quot;
         end
 
         # Explicit field name given, run the operator on the specified field only
-        def to_single_field_sql(definition, &amp;block)
+        def to_single_field_sql(builder, definition, &amp;block)
           raise ScopedSearch::QueryNotSupported, &quot;Field name not a leaf node&quot; unless lhs.kind_of?(ScopedSearch::QueryLanguage::AST::LeafNode)
           raise ScopedSearch::QueryNotSupported, &quot;Value not a leaf node&quot;      unless rhs.kind_of?(ScopedSearch::QueryLanguage::AST::LeafNode)
 
           # Search only on the given field.
           field = definition.fields[lhs.value.to_sym]
           raise ScopedSearch::QueryNotSupported, &quot;Field '#{lhs.value}' not recognized for searching!&quot; unless field
-          ScopedSearch::QueryBuilder.sql_test(field, operator, rhs.value, &amp;block)
+          builder.sql_test(field, operator, rhs.value, &amp;block)
         end
 
         # Convert this AST node to an SQL fragment.
-        def to_sql(definition, &amp;block)
+        def to_sql(builder, definition, &amp;block)
           if operator == :not &amp;&amp; children.length == 1
-            to_not_sql(definition, &amp;block)
+            to_not_sql(builder, definition, &amp;block)
           elsif [:null, :notnull].include?(operator)
-            to_null_sql(definition, &amp;block)
+            to_null_sql(builder, definition, &amp;block)
           elsif children.length == 1
-            to_default_fields_sql(definition, &amp;block)
+            to_default_fields_sql(builder, definition, &amp;block)
           elsif children.length == 2
-            to_single_field_sql(definition, &amp;block)
+            to_single_field_sql(builder, definition, &amp;block)
           else
             raise ScopedSearch::QueryNotSupported, &quot;Don't know how to handle this operator node: #{operator.inspect} with #{children.inspect}!&quot;
           end
@@ -235,12 +245,34 @@ module ScopedSearch
 
       # Defines the to_sql method for AST AND/OR operators
       module LogicalOperatorNode
-        def to_sql(definition, &amp;block)
-          fragments = children.map { |c| c.to_sql(definition, &amp;block) }.compact
+        def to_sql(builder, definition, &amp;block)
+          fragments = children.map { |c| c.to_sql(builder, definition, &amp;block) }.compact
           fragments.empty? ? nil : &quot;(#{fragments.join(&quot; #{operator.to_s.upcase} &quot;)})&quot;
         end
       end
     end
+
+    class MysqlAdapter &lt; ScopedSearch::QueryBuilder
+      
+      def sql_operator(operator, field)
+        if [:ne, :eq].include?(operator) &amp;&amp; field.textual?
+          &quot;#{SQL_OPERATORS[operator]} BINARY&quot;
+        else
+          super(operator, field)
+        end
+      end
+    end
+
+    class PostgreSQLAdapter &lt; ScopedSearch::QueryBuilder
+      
+      def sql_operator(operator, field)
+        case operator
+        when :like   then 'ILIKE'
+        when :unlike then 'NOT ILIKE'
+        else super(operator, field)
+        end
+      end
+    end
   end
 
   # Include the modu;es into the corresponding classes</diff>
      <filename>lib/scoped_search/query_builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,11 @@
+# rake spec will try to run the integration specs on all the following 
+# database connections to test the different adapters.
+#
+# The syntax of this file is similar to the database.yml file in a
+# Rails application. You can change these parameters to your setup,
+# or comment them out if you have no such database connections available
+# to you.
+
 sqlite3:
   adapter: &quot;sqlite3&quot;
   database: &quot;:memory:&quot;
@@ -8,10 +16,10 @@ mysql:
   user: &quot;root&quot;
   password:
   database: &quot;scoped_search_test&quot;
-
+ 
 postgresql:
   adapter: &quot;postgresql&quot;
   host: &quot;localhost&quot;
-  username: &quot;sstest&quot;
-  password: &quot;sstest&quot;
+  username: &quot;scoped_search&quot;
+  password: &quot;scoped_search&quot;
   database: &quot;scoped_search_test&quot;</diff>
      <filename>spec/database.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,153 +1,158 @@
 require &quot;#{File.dirname(__FILE__)}/../spec_helper&quot;
 
-describe ScopedSearch do
+# These specs will run on all databases that are defined in the spec/database.yml file.
+# Comment out any databases that you do not have available for testing purposes if needed.
+ScopedSearch::Spec::Database.test_databases.each do |db|
+  
+  describe ScopedSearch, &quot;using a #{db} database&quot; do
 
-  before(:all) do
-    ScopedSearch::Spec::Database.establish_connection
+    before(:all) do
+      ScopedSearch::Spec::Database.establish_named_connection(db)
 
-    @class = ScopedSearch::Spec::Database.create_model(:int =&gt; :integer, :timestamp =&gt; :datetime, :date =&gt; :date, :unindexed =&gt; :integer) do |klass|
-      klass.scoped_search :on =&gt; [:int, :timestamp]
-      klass.scoped_search :on =&gt; :date, :only_explicit =&gt; true
+      @class = ScopedSearch::Spec::Database.create_model(:int =&gt; :integer, :timestamp =&gt; :datetime, :date =&gt; :date, :unindexed =&gt; :integer) do |klass|
+        klass.scoped_search :on =&gt; [:int, :timestamp]
+        klass.scoped_search :on =&gt; :date, :only_explicit =&gt; true
+      end
     end
-  end
 
-  after(:all) do
-    ScopedSearch::Spec::Database.drop_model(@class)
-    ScopedSearch::Spec::Database.close_connection
-  end
+    after(:all) do
+      ScopedSearch::Spec::Database.drop_model(@class)
+      ScopedSearch::Spec::Database.close_connection
+    end
 
-  context 'quering numerical fields' do
+    context 'quering numerical fields' do
 
-    before(:all) do
-      @record = @class.create!(:int =&gt;  9)
-    end
+      before(:all) do
+        @record = @class.create!(:int =&gt;  9)
+      end
 
-    after(:all) do
-      @record.destroy
-    end
+      after(:all) do
+        @record.destroy
+      end
 
-    it &quot;should find the record with an exact integer match&quot; do
-      @class.search_for('9').should have(1).item
-    end
+      it &quot;should find the record with an exact integer match&quot; do
+        @class.search_for('9').should have(1).item
+      end
 
-    it &quot;should find the record with an exact integer match with an explicit operator&quot; do
-      @class.search_for('= 9').should have(1).item
-    end
+      it &quot;should find the record with an exact integer match with an explicit operator&quot; do
+        @class.search_for('= 9').should have(1).item
+      end
 
-    it &quot;should find the record with an exact integer match with an explicit field name&quot; do
-      @class.search_for('int = 9').should have(1).item
-    end
+      it &quot;should find the record with an exact integer match with an explicit field name&quot; do
+        @class.search_for('int = 9').should have(1).item
+      end
 
-    it &quot;should find the record with an exact integer match with an explicit field name&quot; do
-      @class.search_for('int &gt; 8').should have(1).item
-    end
+      it &quot;should find the record with an exact integer match with an explicit field name&quot; do
+        @class.search_for('int &gt; 8').should have(1).item
+      end
 
-    it &quot;should find the record with a grater than operator and explicit field&quot; do
-      @class.search_for('int &gt; 9').should have(0).item
-    end
+      it &quot;should find the record with a grater than operator and explicit field&quot; do
+        @class.search_for('int &gt; 9').should have(0).item
+      end
 
-    it &quot;should find the record with an &gt;= operator with an implicit field name&quot; do
-      @class.search_for('&gt;= 9').should have(1).item
-    end
+      it &quot;should find the record with an &gt;= operator with an implicit field name&quot; do
+        @class.search_for('&gt;= 9').should have(1).item
+      end
 
-    it &quot;should not return the record if only one predicate is true and AND is used (by default)&quot; do
-      @class.search_for('int &lt;= 8, int &gt; 8').should have(0).item
-    end
+      it &quot;should not return the record if only one predicate is true and AND is used (by default)&quot; do
+        @class.search_for('int &lt;= 8, int &gt; 8').should have(0).item
+      end
 
-    it &quot;should return the record in only one predicate is true and OR is used as operator&quot; do
-      @class.search_for('int &lt;= 8 || int &gt; 8').should have(1).item
+      it &quot;should return the record in only one predicate is true and OR is used as operator&quot; do
+        @class.search_for('int &lt;= 8 || int &gt; 8').should have(1).item
+      end
     end
-  end
 
-  context 'querying unindexed fields' do
+    context 'querying unindexed fields' do
 
-    before(:all) do
-      @record = @class.create!(:int =&gt;  9, :unindexed =&gt; 10)
-    end
+      before(:all) do
+        @record = @class.create!(:int =&gt;  9, :unindexed =&gt; 10)
+      end
 
-    after(:all) do
-      @record.destroy
-    end
+      after(:all) do
+        @record.destroy
+      end
 
-    it &quot;should raise an error when explicitly searching in the non-indexed column&quot; do
-      lambda { @class.search_for('unindexed = 10') }.should raise_error(ScopedSearch::Exception)
-    end
+      it &quot;should raise an error when explicitly searching in the non-indexed column&quot; do
+        lambda { @class.search_for('unindexed = 10') }.should raise_error(ScopedSearch::Exception)
+      end
 
-    it &quot;should not return records for which the query matches unindex records&quot; do
-      @class.search_for('= 10').should have(0).item
+      it &quot;should not return records for which the query matches unindex records&quot; do
+        @class.search_for('= 10').should have(0).item
+      end
     end
-  end
 
-  context 'querying date and time fields' do
+    context 'querying date and time fields' do
 
-    before(:all) do
-      @record = @class.create!(:timestamp =&gt; Time.parse('2009-01-02 14:51:44'), :date =&gt; Date.parse('2009-01-02'))
-      @nil_record = @class.create!(:timestamp =&gt; nil, :date =&gt; nil)
-    end
+      before(:all) do
+        @record = @class.create!(:timestamp =&gt; Time.parse('2009-01-02 14:51:44'), :date =&gt; Date.parse('2009-01-02'))
+        @nil_record = @class.create!(:timestamp =&gt; nil, :date =&gt; nil)
+      end
 
-    after(:all) do
-      @record.destroy
-      @nil_record.destroy
-    end
+      after(:all) do
+        @record.destroy
+        @nil_record.destroy
+      end
 
-    it &quot;should accept YYYY-MM-DD as date format&quot; do
-      @class.search_for('date = 2009-01-02').should have(1).item
-    end
+      it &quot;should accept YYYY-MM-DD as date format&quot; do
+        @class.search_for('date = 2009-01-02').should have(1).item
+      end
 
-    it &quot;should accept YY-MM-DD as date format&quot; do
-      @class.search_for('date = 09-01-02').should have(1).item
-    end
+      it &quot;should accept YY-MM-DD as date format&quot; do
+        @class.search_for('date = 09-01-02').should have(1).item
+      end
 
-    it &quot;should accept MM/DD/YY as date format&quot; do
-      @class.search_for('date = 01/02/09').should have(1).item
-    end
+      it &quot;should accept MM/DD/YY as date format&quot; do
+        @class.search_for('date = 01/02/09').should have(1).item
+      end
 
-    it &quot;should accept YYYY/MM/DD as date format&quot; do
-      @class.search_for('date = 2009/01/02').should have(1).item
-    end
+      it &quot;should accept YYYY/MM/DD as date format&quot; do
+        @class.search_for('date = 2009/01/02').should have(1).item
+      end
 
-    it &quot;should accept MM/DD/YYYY as date format&quot; do
-      @class.search_for('date = 01/02/2009').should have(1).item
-    end
+      it &quot;should accept MM/DD/YYYY as date format&quot; do
+        @class.search_for('date = 01/02/2009').should have(1).item
+      end
 
-    it &quot;should ignore an invalid date and thus return all records&quot; do
-      @class.search_for('&gt;= 2009-14-57').should have(2).items
-    end
+      it &quot;should ignore an invalid date and thus return all records&quot; do
+        @class.search_for('&gt;= 2009-14-57').should have(2).items
+      end
 
-    it &quot;should find the records with a timestamp set some point on the provided date&quot; do
-      @class.search_for('&gt;= 2009-01-02').should have(1).item
-    end
+      it &quot;should find the records with a timestamp set some point on the provided date&quot; do
+        @class.search_for('&gt;= 2009-01-02').should have(1).item
+      end
 
-    it &quot;should support full timestamps&quot; do
-      @class.search_for('&gt; &quot;2009-01-02 02:02:02&quot;').should have(1).item
-    end
+      it &quot;should support full timestamps&quot; do
+        @class.search_for('&gt; &quot;2009-01-02 02:02:02&quot;').should have(1).item
+      end
 
-    it &quot;should find no record with a timestamp in the past&quot; do
-      @class.search_for('&lt; 2009-01-02').should have(0).item
-    end
+      it &quot;should find no record with a timestamp in the past&quot; do
+        @class.search_for('&lt; 2009-01-02').should have(0).item
+      end
 
-    it &quot;should find all timestamps on a date if no time is given using the = operator&quot; do
-      @class.search_for('= 2009-01-02').should have(1).item
-    end
+      it &quot;should find all timestamps on a date if no time is given using the = operator&quot; do
+        @class.search_for('= 2009-01-02').should have(1).item
+      end
 
-    it &quot;should find all timestamps on a date if no time is when no operator is given&quot; do
-      @class.search_for('2009-01-02').should have(1).item
-    end
+      it &quot;should find all timestamps on a date if no time is when no operator is given&quot; do
+        @class.search_for('2009-01-02').should have(1).item
+      end
 
-    it &quot;should find all timestamps not on a date if no time is given using the != operator&quot; do
-      @class.search_for('!= 2009-01-02').should have(0).item
-    end
+      it &quot;should find all timestamps not on a date if no time is given using the != operator&quot; do
+        @class.search_for('!= 2009-01-02').should have(0).item
+      end
 
-    it &quot;should find the records when the date part of a timestamp matches a date&quot; do
-      @class.search_for('&gt;= 2009-01-02').should have(1).item
-    end
+      it &quot;should find the records when the date part of a timestamp matches a date&quot; do
+        @class.search_for('&gt;= 2009-01-02').should have(1).item
+      end
 
-    it &quot;should find the record with the timestamp today or in the past&quot; do
-      @class.search_for('&lt;= 2009-01-02').should have(1).item
-    end
+      it &quot;should find the record with the timestamp today or in the past&quot; do
+        @class.search_for('&lt;= 2009-01-02').should have(1).item
+      end
 
-    it &quot;should find no record with a timestamp later than today&quot; do
-      @class.search_for('&gt; 2009-01-02').should have(0).item
+      it &quot;should find no record with a timestamp later than today&quot; do
+        @class.search_for('&gt; 2009-01-02').should have(0).item
+      end
     end
   end
 end</diff>
      <filename>spec/integration/ordinal_querying_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,258 +1,262 @@
 require &quot;#{File.dirname(__FILE__)}/../spec_helper&quot;
 
-describe ScopedSearch do
+# These specs will run on all databases that are defined in the spec/database.yml file.
+# Comment out any databases that you do not have available for testing purposes if needed.
+ScopedSearch::Spec::Database.test_databases.each do |db|
 
-  before(:all) do
-    ScopedSearch::Spec::Database.establish_connection
-  end
+  describe ScopedSearch, &quot;using a #{db} database&quot; do
 
-  after(:all) do
-    ScopedSearch::Spec::Database.close_connection
-  end
+    before(:all) do
+      ScopedSearch::Spec::Database.establish_named_connection(db)
+    end
 
-  context 'querying a :belongs_to relation' do
+    after(:all) do
+      ScopedSearch::Spec::Database.close_connection
+    end
 
-    before(:all) do
+    context 'querying a :belongs_to relation' do
+
+      before(:all) do
+
+        # The related class
+        ActiveRecord::Migration.create_table(:bars) { |t| t.string :related }
+        class Bar &lt; ActiveRecord::Base; has_many :foos; end
 
-      # The related class
-      ActiveRecord::Migration.create_table(:bars) { |t| t.string :related }
-      class Bar &lt; ActiveRecord::Base; has_many :foos; end
+        # The class on which to call search_for
+        Foo = ScopedSearch::Spec::Database.create_model(:foo =&gt; :string, :bar_id =&gt; :integer) do |klass|
+          klass.belongs_to :bar
+          klass.scoped_search :in =&gt; :bar, :on =&gt; :related
+        end
 
-      # The class on which to call search_for
-      Foo = ScopedSearch::Spec::Database.create_model(:foo =&gt; :string, :bar_id =&gt; :integer) do |klass|
-        klass.belongs_to :bar
-        klass.scoped_search :in =&gt; :bar, :on =&gt; :related
+        @bar_record = Bar.create!(:related =&gt; 'bar')
+
+        Foo.create!(:foo =&gt; 'foo',       :bar =&gt; @bar_record)
+        Foo.create!(:foo =&gt; 'foo too',   :bar =&gt; @bar_record)
+        Foo.create!(:foo =&gt; 'foo three', :bar =&gt; Bar.create!(:related =&gt; 'another bar'))
+        Foo.create!(:foo =&gt; 'foo four')
       end
 
-      @bar_record = Bar.create!(:related =&gt; 'bar')
+      after(:all) do
+        ScopedSearch::Spec::Database.drop_model(Bar)
+        ScopedSearch::Spec::Database.drop_model(Foo)
+        Object.send :remove_const, :Foo
+        Object.send :remove_const, :Bar
+      end
 
-      Foo.create!(:foo =&gt; 'foo',       :bar =&gt; @bar_record)
-      Foo.create!(:foo =&gt; 'foo too',   :bar =&gt; @bar_record)
-      Foo.create!(:foo =&gt; 'foo three', :bar =&gt; Bar.create!(:related =&gt; 'another bar'))
-      Foo.create!(:foo =&gt; 'foo four')
-    end
+      it &quot;should find all records with a related bar record containing bar&quot; do
+        Foo.search_for('bar').should have(3).items
+      end
 
-    after(:all) do
-      ScopedSearch::Spec::Database.drop_model(Bar)
-      ScopedSearch::Spec::Database.drop_model(Foo)
-      Object.send :remove_const, :Foo
-      Object.send :remove_const, :Bar
-    end
+      it &quot;should find all records with a related bar record having an exact value of bar&quot; do
+        Foo.search_for('= bar').should have(2).items
+      end
 
-    it &quot;should find all records with a related bar record containing bar&quot; do
-      Foo.search_for('bar').should have(3).items
-    end
+      it &quot;should find all records with a related bar record having an exact value of bar with an explicit field&quot; do
+         Foo.search_for('related = bar').should have(2).items
+       end
 
-    it &quot;should find all records with a related bar record having an exact value of bar&quot; do
-      Foo.search_for('= bar').should have(2).items
+      it &quot;should find records for which the bar relation is not set using null?&quot; do
+        Foo.search_for('null? related').should have(1).items
+      end
     end
 
-    it &quot;should find all records with a related bar record having an exact value of bar with an explicit field&quot; do
-       Foo.search_for('related = bar').should have(2).items
-     end
+    context 'querying a :has_many relation' do
 
-    it &quot;should find records for which the bar relation is not set using null?&quot; do
-      Foo.search_for('null? related').should have(1).items
-    end
-  end
+      before(:all) do
 
-  context 'querying a :has_many relation' do
+        # The related class
+        ActiveRecord::Migration.create_table(:bars) { |t| t.string :related; t.integer :foo_id }
+        class Bar &lt; ActiveRecord::Base; belongs_to :foo; end
 
-    before(:all) do
+        # The class on which to call search_for
+        Foo = ScopedSearch::Spec::Database.create_model(:foo =&gt; :string, :bar_id =&gt; :integer) do |klass|
+          klass.has_many :bars
+          klass.scoped_search :in =&gt; :bars, :on =&gt; :related
+        end
 
-      # The related class
-      ActiveRecord::Migration.create_table(:bars) { |t| t.string :related; t.integer :foo_id }
-      class Bar &lt; ActiveRecord::Base; belongs_to :foo; end
+        @foo_1 = Foo.create!(:foo =&gt; 'foo')
+        @foo_2 = Foo.create!(:foo =&gt; 'foo too')
+        @foo_3 = Foo.create!(:foo =&gt; 'foo three')
 
-      # The class on which to call search_for
-      Foo = ScopedSearch::Spec::Database.create_model(:foo =&gt; :string, :bar_id =&gt; :integer) do |klass|
-        klass.has_many :bars
-        klass.scoped_search :in =&gt; :bars, :on =&gt; :related
+        Bar.create!(:related =&gt; 'bar',         :foo =&gt; @foo_1)
+        Bar.create!(:related =&gt; 'another bar', :foo =&gt; @foo_1)
+        Bar.create!(:related =&gt; 'other bar',   :foo =&gt; @foo_2)
       end
 
-      @foo_1 = Foo.create!(:foo =&gt; 'foo')
-      @foo_2 = Foo.create!(:foo =&gt; 'foo too')
-      @foo_3 = Foo.create!(:foo =&gt; 'foo three')
+      after(:all) do
+        ScopedSearch::Spec::Database.drop_model(Bar)
+        ScopedSearch::Spec::Database.drop_model(Foo)
+        Object.send :remove_const, :Foo
+        Object.send :remove_const, :Bar
+      end
 
-      Bar.create!(:related =&gt; 'bar',         :foo =&gt; @foo_1)
-      Bar.create!(:related =&gt; 'another bar', :foo =&gt; @foo_1)
-      Bar.create!(:related =&gt; 'other bar',   :foo =&gt; @foo_2)
-    end
+      it &quot;should find all records with at least one bar record containing 'bar'&quot; do
+        Foo.search_for('bar').should have(2).items
+      end
 
-    after(:all) do
-      ScopedSearch::Spec::Database.drop_model(Bar)
-      ScopedSearch::Spec::Database.drop_model(Foo)
-      Object.send :remove_const, :Foo
-      Object.send :remove_const, :Bar
-    end
+      it &quot;should find the only record with at least one bar record having the exact value 'bar'&quot; do
+        Foo.search_for('= bar').should have(1).item
+      end
 
-    it &quot;should find all records with at least one bar record containing 'bar'&quot; do
-      Foo.search_for('bar').should have(2).items
-    end
+      it &quot;should find all records for which at least one related bar record exists&quot; do
+        Foo.search_for('set? related').should have(2).items
+      end
 
-    it &quot;should find the only record with at least one bar record having the exact value 'bar'&quot; do
-      Foo.search_for('= bar').should have(1).item
-    end
+      it &quot;should find all records for which none related bar records exist&quot; do
+        Foo.search_for('null? related').should have(1).items
+      end
 
-    it &quot;should find all records for which at least one related bar record exists&quot; do
-      Foo.search_for('set? related').should have(2).items
     end
 
-    it &quot;should find all records for which none related bar records exist&quot; do
-      Foo.search_for('null? related').should have(1).items
-    end
+    context 'querying a :has_one relation' do
 
-  end
+      before(:all) do
 
-  context 'querying a :has_one relation' do
+        # The related class
+        ActiveRecord::Migration.create_table(:bars) { |t| t.string :related; t.integer :foo_id }
+        class Bar &lt; ActiveRecord::Base; belongs_to :foo; end
 
-    before(:all) do
+        # The class on which to call search_for
+        Foo = ScopedSearch::Spec::Database.create_model(:foo =&gt; :string) do |klass|
+          klass.has_one :bar
+          klass.scoped_search :in =&gt; :bar, :on =&gt; :related
+        end
+
+        @foo_1 = Foo.create!(:foo =&gt; 'foo')
+        @foo_2 = Foo.create!(:foo =&gt; 'foo too')
+        @foo_3 = Foo.create!(:foo =&gt; 'foo three')
 
-      # The related class
-      ActiveRecord::Migration.create_table(:bars) { |t| t.string :related; t.integer :foo_id }
-      class Bar &lt; ActiveRecord::Base; belongs_to :foo; end
+        Bar.create!(:related =&gt; 'bar',         :foo =&gt; @foo_1)
+        Bar.create!(:related =&gt; 'other bar',   :foo =&gt; @foo_2)
+      end
 
-      # The class on which to call search_for
-      Foo = ScopedSearch::Spec::Database.create_model(:foo =&gt; :string) do |klass|
-        klass.has_one :bar
-        klass.scoped_search :in =&gt; :bar, :on =&gt; :related
+      after(:all) do
+        ScopedSearch::Spec::Database.drop_model(Bar)
+        ScopedSearch::Spec::Database.drop_model(Foo)
+        Object.send :remove_const, :Foo
+        Object.send :remove_const, :Bar
       end
 
-      @foo_1 = Foo.create!(:foo =&gt; 'foo')
-      @foo_2 = Foo.create!(:foo =&gt; 'foo too')
-      @foo_3 = Foo.create!(:foo =&gt; 'foo three')
+      it &quot;should find all records with a bar record containing 'bar&quot; do
+        Foo.search_for('bar').should have(2).items
+      end
 
-      Bar.create!(:related =&gt; 'bar',         :foo =&gt; @foo_1)
-      Bar.create!(:related =&gt; 'other bar',   :foo =&gt; @foo_2)
-    end
+      it &quot;should find the only record with the bar record has the exact value 'bar&quot; do
+        Foo.search_for('= bar').should have(1).item
+      end
 
-    after(:all) do
-      ScopedSearch::Spec::Database.drop_model(Bar)
-      ScopedSearch::Spec::Database.drop_model(Foo)
-      Object.send :remove_const, :Foo
-      Object.send :remove_const, :Bar
-    end
+      it &quot;should find all records for which the related bar record exists&quot; do
+        Foo.search_for('set? related').should have(2).items
+      end
 
-    it &quot;should find all records with a bar record containing 'bar&quot; do
-      Foo.search_for('bar').should have(2).items
+      it &quot;should find all records for which the related bar record does not exist&quot; do
+        Foo.search_for('null? related').should have(1).items
+      end
     end
 
-    it &quot;should find the only record with the bar record has the exact value 'bar&quot; do
-      Foo.search_for('= bar').should have(1).item
-    end
+    context 'querying a :has_and_belongs_to_many relation' do
 
-    it &quot;should find all records for which the related bar record exists&quot; do
-      Foo.search_for('set? related').should have(2).items
-    end
+      before(:all) do
 
-    it &quot;should find all records for which the related bar record does not exist&quot; do
-      Foo.search_for('null? related').should have(1).items
-    end
-  end
+        # Create some tables
+        ActiveRecord::Migration.create_table(:bars) { |t| t.string :related }
+        ActiveRecord::Migration.create_table(:bars_foos, :id =&gt; false) { |t| t.integer :foo_id; t.integer :bar_id }
+        ActiveRecord::Migration.create_table(:foos) { |t| t.string :foo }
 
-  context 'querying a :has_and_belongs_to_many relation' do
+        # The related class
+        class Bar &lt; ActiveRecord::Base; end
 
-    before(:all) do
+        # The class on which to call search_for
+        class Foo &lt; ActiveRecord::Base
+          has_and_belongs_to_many :bars
+          scoped_search :in =&gt; :bars, :on =&gt; :related
+        end
 
-      # Create some tables
-      ActiveRecord::Migration.create_table(:bars) { |t| t.string :related }
-      ActiveRecord::Migration.create_table(:bars_foos, :id =&gt; false) { |t| t.integer :foo_id; t.integer :bar_id }
-      ActiveRecord::Migration.create_table(:foos) { |t| t.string :foo }
+        @foo_1 = Foo.create!(:foo =&gt; 'foo')
+        @foo_2 = Foo.create!(:foo =&gt; 'foo too')
+        @foo_3 = Foo.create!(:foo =&gt; 'foo three')
 
-      # The related class
-      class Bar &lt; ActiveRecord::Base; end
+        @bar_1 = Bar.create!(:related =&gt; 'bar')
+        @bar_2 = Bar.create!(:related =&gt; 'other bar')
+        @bar_3 = Bar.create!(:related =&gt; 'last bar')
 
-      # The class on which to call search_for
-      class Foo &lt; ActiveRecord::Base
-        has_and_belongs_to_many :bars
-        scoped_search :in =&gt; :bars, :on =&gt; :related
+        @foo_1.bars &lt;&lt; @bar_1 &lt;&lt; @bar_2
+        @foo_2.bars &lt;&lt; @bar_2 &lt;&lt; @bar_3
       end
 
-      @foo_1 = Foo.create!(:foo =&gt; 'foo')
-      @foo_2 = Foo.create!(:foo =&gt; 'foo too')
-      @foo_3 = Foo.create!(:foo =&gt; 'foo three')
+      after(:all) do
+        ActiveRecord::Migration.drop_table(:bars_foos)
+        ActiveRecord::Migration.drop_table(:bars)
+        ActiveRecord::Migration.drop_table(:foos)
+        Object.send :remove_const, :Foo
+        Object.send :remove_const, :Bar
+      end
 
-      @bar_1 = Bar.create!(:related =&gt; 'bar')
-      @bar_2 = Bar.create!(:related =&gt; 'other bar')
-      @bar_3 = Bar.create!(:related =&gt; 'last bar')
+      it &quot;should find all records with at least one associated bar record containing 'bar'&quot; do
+        Foo.search_for('bar').should have(2).items
+      end
 
-      @foo_1.bars &lt;&lt; @bar_1 &lt;&lt; @bar_2
-      @foo_2.bars &lt;&lt; @bar_2 &lt;&lt; @bar_3
-    end
+      it &quot;should find record which is related to @bar_1&quot; do
+        Foo.search_for('= bar').should have(1).items
+      end
 
-    after(:all) do
-      ActiveRecord::Migration.drop_table(:bars_foos)
-      ActiveRecord::Migration.drop_table(:bars)
-      ActiveRecord::Migration.drop_table(:foos)
-      Object.send :remove_const, :Foo
-      Object.send :remove_const, :Bar
-    end
+      it &quot;should find the only record related to @bar_3&quot; do
+        Foo.search_for('last').should have(1).items
+      end
 
-    it &quot;should find all records with at least one associated bar record containing 'bar'&quot; do
-      Foo.search_for('bar').should have(2).items
+      it &quot;should find all records that are related to @bar_2&quot; do
+        Foo.search_for('other').should have(2).items
+      end
     end
 
-    it &quot;should find record which is related to @bar_1&quot; do
-      Foo.search_for('= bar').should have(1).items
-    end
+    context 'querying a :has_many =&gt; :through relation' do
 
-    it &quot;should find the only record related to @bar_3&quot; do
-      Foo.search_for('last').should have(1).items
-    end
+      before(:all) do
 
-    it &quot;should find all records that are related to @bar_2&quot; do
-      Foo.search_for('other').should have(2).items
-    end
-  end
+        # Create some tables
+        ActiveRecord::Migration.create_table(:bars) { |t| t.integer :foo_id; t.integer :baz_id }
+        ActiveRecord::Migration.create_table(:bazs) { |t| t.string :related }
+        ActiveRecord::Migration.create_table(:foos) { |t| t.string :foo }
 
-  context 'querying a :has_many =&gt; :through relation' do
+        # The related classes
+        class Bar &lt; ActiveRecord::Base; belongs_to :baz; belongs_to :foo; end
+        class Baz &lt; ActiveRecord::Base; has_many :bars; end
 
-    before(:all) do
+        # The class on which to call search_for
+        class Foo &lt; ActiveRecord::Base
+          has_many :bars
+          has_many :bazs, :through =&gt; :bars
 
-      # Create some tables
-      ActiveRecord::Migration.create_table(:bars) { |t| t.integer :foo_id; t.integer :baz_id }
-      ActiveRecord::Migration.create_table(:bazs) { |t| t.string :related }
-      ActiveRecord::Migration.create_table(:foos) { |t| t.string :foo }
+          scoped_search :in =&gt; :bazs, :on =&gt; :related
+        end
 
-      # The related classes
-      class Bar &lt; ActiveRecord::Base; belongs_to :baz; belongs_to :foo; end
-      class Baz &lt; ActiveRecord::Base; has_many :bars; end
+        @foo_1 = Foo.create!(:foo =&gt; 'foo')
+        @foo_2 = Foo.create!(:foo =&gt; 'foo too')
+        @foo_3 = Foo.create!(:foo =&gt; 'foo three')
 
-      # The class on which to call search_for
-      class Foo &lt; ActiveRecord::Base
-        has_many :bars
-        has_many :bazs, :through =&gt; :bars
+        @baz_1 = Baz.create(:related =&gt; 'baz')
+        @baz_2 = Baz.create(:related =&gt; 'baz too!')
 
-        scoped_search :in =&gt; :bazs, :on =&gt; :related
+        @bar_1 = Bar.create!(:foo =&gt; @foo_1, :baz =&gt; @baz_1)
+        @bar_2 = Bar.create!(:foo =&gt; @foo_1)
+        @bar_3 = Bar.create!(:foo =&gt; @foo_2, :baz =&gt; @baz_1)
+        @bar_3 = Bar.create!(:foo =&gt; @foo_2, :baz =&gt; @baz_2)
+        @bar_3 = Bar.create!(:foo =&gt; @foo_2, :baz =&gt; @baz_2)
+        @bar_4 = Bar.create!(:foo =&gt; @foo_3)
       end
 
-      @foo_1 = Foo.create!(:foo =&gt; 'foo')
-      @foo_2 = Foo.create!(:foo =&gt; 'foo too')
-      @foo_3 = Foo.create!(:foo =&gt; 'foo three')
-
-      @baz_1 = Baz.create(:related =&gt; 'baz')
-      @baz_2 = Baz.create(:related =&gt; 'baz too!')
-
-      @bar_1 = Bar.create!(:foo =&gt; @foo_1, :baz =&gt; @baz_1)
-      @bar_2 = Bar.create!(:foo =&gt; @foo_1)
-      @bar_3 = Bar.create!(:foo =&gt; @foo_2, :baz =&gt; @baz_1)
-      @bar_3 = Bar.create!(:foo =&gt; @foo_2, :baz =&gt; @baz_2)
-      @bar_3 = Bar.create!(:foo =&gt; @foo_2, :baz =&gt; @baz_2)
-      @bar_4 = Bar.create!(:foo =&gt; @foo_3)
-    end
-
-    after(:all) do
-      ActiveRecord::Migration.drop_table(:bazs)
-      ActiveRecord::Migration.drop_table(:bars)
-      ActiveRecord::Migration.drop_table(:foos)
-      Object.send :remove_const, :Foo
-      Object.send :remove_const, :Bar
-      Object.send :remove_const, :Baz
-    end
+      after(:all) do
+        ActiveRecord::Migration.drop_table(:bazs)
+        ActiveRecord::Migration.drop_table(:bars)
+        ActiveRecord::Migration.drop_table(:foos)
+        Object.send :remove_const, :Foo
+        Object.send :remove_const, :Bar
+        Object.send :remove_const, :Baz
+      end
 
-    it &quot;should find the two records that are related to a baz record&quot; do
-      Foo.search_for('baz').should have(2).items
+      it &quot;should find the two records that are related to a baz record&quot; do
+        Foo.search_for('baz').should have(2).items
+      end
     end
   end
-
 end</diff>
      <filename>spec/integration/relation_querying_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,187 +1,192 @@
 require &quot;#{File.dirname(__FILE__)}/../spec_helper&quot;
 
-describe ScopedSearch, :search_for do
-
-  before(:all) do
-    ScopedSearch::Spec::Database.establish_connection
-    @class = ScopedSearch::Spec::Database.create_model(:string =&gt; :string, :another =&gt; :string, :explicit =&gt; :string) do |klass|
-      klass.scoped_search :on =&gt; :string
-      klass.scoped_search :on =&gt; :another,  :default_operator =&gt; :eq, :alias =&gt; :alias
-      klass.scoped_search :on =&gt; :explicit, :only_explicit =&gt; true
-    end
+# These specs will run on all databases that are defined in the spec/database.yml file.
+# Comment out any databases that you do not have available for testing purposes if needed.
+ScopedSearch::Spec::Database.test_databases.each do |db|
 
-    @class.create!(:string =&gt; 'foo', :another =&gt; 'temp 1', :explicit =&gt; 'baz')
-    @class.create!(:string =&gt; 'bar', :another =&gt; 'temp 2', :explicit =&gt; 'baz')
-    @class.create!(:string =&gt; 'baz', :another =&gt; 'temp 3', :explicit =&gt; nil)
-  end
+  describe ScopedSearch, &quot;using a #{db} database&quot; do
 
-  after(:all) do
-    ScopedSearch::Spec::Database.drop_model(@class)
-    ScopedSearch::Spec::Database.close_connection
-  end
+    before(:all) do
+      ScopedSearch::Spec::Database.establish_named_connection(db)
+    
+      @class = ScopedSearch::Spec::Database.create_model(:string =&gt; :string, :another =&gt; :string, :explicit =&gt; :string) do |klass|
+        klass.scoped_search :on =&gt; :string
+        klass.scoped_search :on =&gt; :another,  :default_operator =&gt; :eq, :alias =&gt; :alias
+        klass.scoped_search :on =&gt; :explicit, :only_explicit =&gt; true
+      end
 
-  context 'in an implicit string field' do
-    it &quot;should find the record with an exact string match&quot; do
-      @class.search_for('foo').should have(1).item
+      @class.create!(:string =&gt; 'foo', :another =&gt; 'temp 1', :explicit =&gt; 'baz')
+      @class.create!(:string =&gt; 'bar', :another =&gt; 'temp 2', :explicit =&gt; 'baz')
+      @class.create!(:string =&gt; 'baz', :another =&gt; 'temp 3', :explicit =&gt; nil)
     end
 
-    it &quot;should find the opther two records using NOT with an exact string match&quot; do
-      @class.search_for('-foo').should have(2).item
+    after(:all) do
+      ScopedSearch::Spec::Database.drop_model(@class)
+      ScopedSearch::Spec::Database.close_connection
     end
 
-    it &quot;should find the record with an exact string match and an explicit field operator&quot; do
-      @class.search_for('string = foo').should have(1).item
-    end
+    context 'in an implicit string field' do
+      it &quot;should find the record with an exact string match&quot; do
+        @class.search_for('foo').should have(1).item
+      end
 
-    it &quot;should find the record with an exact string match and an explicit field operator&quot; do
-      @class.search_for('another = foo').should have(0).items
-    end
+      it &quot;should find the opther two records using NOT with an exact string match&quot; do
+        @class.search_for('-foo').should have(2).item
+      end
 
-    it &quot;should find the record with an partial string match&quot; do
-      @class.search_for('fo').should have(1).item
-    end
+      it &quot;should find the record with an exact string match and an explicit field operator&quot; do
+        @class.search_for('string = foo').should have(1).item
+      end
 
-    it &quot;should find the other two records using NOT with an partial string match&quot; do
-      @class.search_for('-fo').should have(2).item
-    end
+      it &quot;should find the record with an exact string match and an explicit field operator&quot; do
+        @class.search_for('another = foo').should have(0).items
+      end
 
-    it &quot;should not find the record with an explicit equals operator and a partial match&quot; do
-      @class.search_for('= fo').should have(0).items
-    end
+      it &quot;should find the record with an partial string match&quot; do
+        @class.search_for('fo').should have(1).item
+      end
 
-    it &quot;should find the record with an explicit LIKE operator and a partial match&quot; do
-      @class.search_for('~ fo').should have(1).items
-    end
+      it &quot;should find the other two records using NOT with an partial string match&quot; do
+        @class.search_for('-fo').should have(2).item
+      end
 
-    it &quot;should find the all other record with an explicit NOT LIKE operator and a partial match&quot; do
-      @class.search_for('string !~ fo').should have(@class.count - 1).items
-    end
+      it &quot;should not find the record with an explicit equals operator and a partial match&quot; do
+        @class.search_for('= fo').should have(0).items
+      end
 
-    it &quot;should not find a record with a non-match&quot; do
-      @class.search_for('nonsense').should have(0).items
-    end
+      it &quot;should find the record with an explicit LIKE operator and a partial match&quot; do
+        @class.search_for('~ fo').should have(1).items
+      end
 
-    it &quot;should find two records if it partially matches them&quot; do
-      @class.search_for('ba').should have(2).item
-    end
+      it &quot;should find the all other record with an explicit NOT LIKE operator and a partial match&quot; do
+        @class.search_for('string !~ fo').should have(@class.count - 1).items
+      end
 
-    it &quot;should find no records starting with an a&quot; do
-      @class.search_for('a%').should have(0).item
-    end
+      it &quot;should not find a record with a non-match&quot; do
+        @class.search_for('nonsense').should have(0).items
+      end
 
-    it &quot;should find one records ending with an oo&quot; do
-      @class.search_for('%oo').should have(1).item
-    end
+      it &quot;should find two records if it partially matches them&quot; do
+        @class.search_for('ba').should have(2).item
+      end
 
-    it &quot;should find records without case sensitivity when using the LIKE operator&quot; do
-      @class.search_for('string ~ FOO').should have(1).item
-    end
+      it &quot;should find no records starting with an a&quot; do
+        @class.search_for('a%').should have(0).item
+      end
 
-    it &quot;should not find records without case sensitivity when using the = operator&quot; do
-      @class.search_for('string = FOO').should have(0).items
-    end
+      it &quot;should find one records ending with an oo&quot; do
+        @class.search_for('%oo').should have(1).item
+      end
 
-    it &quot;should find records without case sensitivity when using the != operator&quot; do
-      @class.search_for('string != FOO').should have(3).items
-    end
+      it &quot;should find records without case sensitivity when using the LIKE operator&quot; do
+        @class.search_for('string ~ FOO').should have(1).item
+      end
 
-    it &quot;should find records without case sensitivity when using the NOT LIKE operator&quot; do
-      @class.search_for('string !~ FOO').should have(2).items
-    end
+      it &quot;should not find records without case sensitivity when using the = operator&quot; do
+        @class.search_for('string = FOO').should have(0).items
+      end
 
-    it &quot;should find the record if one of the query words match using OR&quot; do
-      @class.search_for('foo OR nonsense').should have(1).item
-    end
+      it &quot;should find records without case sensitivity when using the != operator&quot; do
+        @class.search_for('string != FOO').should have(3).items
+      end
 
-    it &quot;should find no records in one of the AND conditions isn't met&quot; do
-      @class.search_for('foo AND nonsense').should have(0).item
-    end
+      it &quot;should find records without case sensitivity when using the NOT LIKE operator&quot; do
+        @class.search_for('string !~ FOO').should have(2).items
+      end
 
-    it &quot;should find two records every single OR conditions matches one single record&quot; do
-      @class.search_for('foo OR baz').should have(2).item
-    end
+      it &quot;should find the record if one of the query words match using OR&quot; do
+        @class.search_for('foo OR nonsense').should have(1).item
+      end
 
-    it &quot;should find two records every single AND conditions matches one single record&quot; do
-      @class.search_for('foo AND baz').should have(0).item
-    end
-  end
+      it &quot;should find no records in one of the AND conditions isn't met&quot; do
+        @class.search_for('foo AND nonsense').should have(0).item
+      end
 
-  context 'in a field with a different default operator' do
-    it &quot;should find an exact match&quot; do
-      @class.search_for('&quot;temp 1&quot;').should have(1).item
-    end
+      it &quot;should find two records every single OR conditions matches one single record&quot; do
+        @class.search_for('foo OR baz').should have(2).item
+      end
 
-    it &quot;should find the orther records using NOT and an exact match&quot; do
-      @class.search_for('-&quot;temp 1&quot;').should have(2).item
+      it &quot;should find two records every single AND conditions matches one single record&quot; do
+        @class.search_for('foo AND baz').should have(0).item
+      end
     end
 
-    it &quot;should find an explicit match&quot; do
-      @class.search_for('another = &quot;temp 1&quot;').should have(1).item
-    end
+    context 'in a field with a different default operator' do
+      it &quot;should find an exact match&quot; do
+        @class.search_for('&quot;temp 1&quot;').should have(1).item
+      end
 
-    it &quot;should not find a partial match&quot; do
-      @class.search_for('temp').should have(0).item
-    end
+      it &quot;should find the orther records using NOT and an exact match&quot; do
+        @class.search_for('-&quot;temp 1&quot;').should have(2).item
+      end
 
-    it &quot;should find all records using a NOT with a partial match on all records&quot; do
-      @class.search_for('-temp&quot;').should have(3).item
-    end
+      it &quot;should find an explicit match&quot; do
+        @class.search_for('another = &quot;temp 1&quot;').should have(1).item
+      end
 
-    it &quot;should find a partial match when the like operator is given&quot; do
-      @class.search_for('~ temp').should have(3).item
-    end
+      it &quot;should not find a partial match&quot; do
+        @class.search_for('temp').should have(0).item
+      end
+
+      it &quot;should find all records using a NOT with a partial match on all records&quot; do
+        @class.search_for('-temp&quot;').should have(3).item
+      end
 
-    it &quot;should find a partial match when the like operator and the field name is given&quot; do
-      @class.search_for('another ~ temp').should have(3).item
+      it &quot;should find a partial match when the like operator is given&quot; do
+        @class.search_for('~ temp').should have(3).item
+      end
+
+      it &quot;should find a partial match when the like operator and the field name is given&quot; do
+        @class.search_for('another ~ temp').should have(3).item
+      end
     end
-  end
 
-  context 'using an aliased field' do
-    it &quot;should find an explicit match using its alias&quot; do
-      @class.search_for('alias = &quot;temp 1&quot;').should have(1).item
+    context 'using an aliased field' do
+      it &quot;should find an explicit match using its alias&quot; do
+        @class.search_for('alias = &quot;temp 1&quot;').should have(1).item
+      end
     end
-  end
 
-  context 'in an explicit string field' do
+    context 'in an explicit string field' do
 
-    it &quot;should not find the records if the explicit field is not given in the query&quot; do
-      @class.search_for('= baz').should have(1).item
-    end
+      it &quot;should not find the records if the explicit field is not given in the query&quot; do
+        @class.search_for('= baz').should have(1).item
+      end
 
-    it &quot;should find all records when searching on the explicit field&quot; do
-      @class.search_for('explicit = baz').should have(2).items
-    end
+      it &quot;should find all records when searching on the explicit field&quot; do
+        @class.search_for('explicit = baz').should have(2).items
+      end
 
-    it &quot;should find no records if the value in the explicit field is not an exact match&quot; do
-      @class.search_for('explicit = ba').should have(0).item
-    end
+      it &quot;should find no records if the value in the explicit field is not an exact match&quot; do
+        @class.search_for('explicit = ba').should have(0).item
+      end
 
-    it &quot;should find all records when searching on the explicit field&quot; do
-      @class.search_for('explicit ~ ba').should have(2).items
-    end
+      it &quot;should find all records when searching on the explicit field&quot; do
+        @class.search_for('explicit ~ ba').should have(2).items
+      end
 
-    it &quot;should only find the record with string = foo and explicit = baz&quot; do
-      @class.search_for('foo, explicit = baz').should have(1).item
+      it &quot;should only find the record with string = foo and explicit = baz&quot; do
+        @class.search_for('foo, explicit = baz').should have(1).item
+      end
     end
-  end
 
-  context 'using null? and set? queries' do
+    context 'using null? and set? queries' do
 
-    it &quot;should return all records if the string field is being checked with set?&quot; do
-      @class.search_for('set? string').should have(3).items
-    end
+      it &quot;should return all records if the string field is being checked with set?&quot; do
+        @class.search_for('set? string').should have(3).items
+      end
 
-    it &quot;should return no records if the string field is being checked with null?&quot; do
-      @class.search_for('null? string').should have(0).items
-    end
+      it &quot;should return no records if the string field is being checked with null?&quot; do
+        @class.search_for('null? string').should have(0).items
+      end
 
-    it &quot;should return all records with a value if the string field is being checked with set?&quot; do
-      @class.search_for('set? explicit').should have(2).items
-    end
+      it &quot;should return all records with a value if the string field is being checked with set?&quot; do
+        @class.search_for('set? explicit').should have(2).items
+      end
 
-    it &quot;should return all records without a value if the string field is being checked with null?&quot; do
-      @class.search_for('null? explicit').should have(1).items
+      it &quot;should return all records without a value if the string field is being checked with null?&quot; do
+        @class.search_for('null? explicit').should have(1).items
+      end
     end
-
   end
 end</diff>
      <filename>spec/integration/string_querying_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,11 @@ module ScopedSearch::Spec::Database
     end
   end
 
+  def self.test_databases
+    @database_connections ||= YAML.load(File.read(&quot;#{File.dirname(__FILE__)}/../database.yml&quot;))
+    @database_connections.keys
+  end
+
   def self.establish_named_connection(name)
     @database_connections ||= YAML.load(File.read(&quot;#{File.dirname(__FILE__)}/../database.yml&quot;))
     raise &quot;#{name} database not configured&quot; if @database_connections[name.to_s].nil?</diff>
      <filename>spec/lib/database.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,10 @@
-$:.reject! { |e| e.include? 'TextMate' }
-$: &lt;&lt; File.join(File.dirname(__FILE__), '..', 'lib')
+$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
 
 require 'rubygems'
 require 'spec'
 require 'active_record'
 
 require 'scoped_search'
-require 'scoped_search/query_language'
 
 module ScopedSearch::Spec; end
 </diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ describe ScopedSearch::QueryBuilder do
 
   before(:each) do
     @definition = mock('ScopedSearch::Definition')
+    @definition.stub!(:klass).and_return(Class.new(ActiveRecord::Base))
   end
 
   it &quot;should return empty conditions if the search query is nil&quot; do
@@ -15,7 +16,7 @@ describe ScopedSearch::QueryBuilder do
   end
 
   it &quot;should return empty conditions if the query is whitespace only&quot; do
-    ScopedSearch::QueryBuilder.build_query(@definition, &quot;\t &quot;).should == { }
+    ScopedSearch::QueryBuilder.build_query(@definition, &quot;\t &quot;).should == {  }
   end
 
 end</diff>
      <filename>spec/unit/query_builder_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/scoped_search/adapters.rb</filename>
    </removed>
    <removed>
      <filename>tasks/database_tests.rake</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>63d403df3ae3d34931f3889b4b94c50c61992584</id>
    </parent>
  </parents>
  <author>
    <name>Willem van Bergen</name>
    <email>willem@vanbergen.org</email>
  </author>
  <url>http://github.com/wvanbergen/scoped_search/commit/07bbb16b75ee854d06fae3f39ae338223f84b0f4</url>
  <id>07bbb16b75ee854d06fae3f39ae338223f84b0f4</id>
  <committed-date>2009-10-01T21:35:11-07:00</committed-date>
  <authored-date>2009-10-01T21:35:11-07:00</authored-date>
  <message>Switched from using module inclusion to adapter classes to tailor scoped search's query builder towards the different DBMSs.

Fixed the test suite to run the integration specs on all the databases defined in the spec/database.yml configuration file.</message>
  <tree>4eebfa058f40ffa233afa7ec9c7a1557f74d3a1e</tree>
  <committer>
    <name>Willem van Bergen</name>
    <email>willem@vanbergen.org</email>
  </committer>
</commit>
