pg_search 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +5 -0
- data/Gemfile +0 -7
- data/lib/pg_search.rb +2 -0
- data/lib/pg_search/configuration/column.rb +1 -5
- data/lib/pg_search/extensions/arel.rb +10 -0
- data/lib/pg_search/features/dmetaphone.rb +8 -2
- data/lib/pg_search/features/tsearch.rb +8 -9
- data/lib/pg_search/multisearch/rebuilder.rb +11 -11
- data/lib/pg_search/normalizer.rb +1 -1
- data/lib/pg_search/tasks.rb +3 -3
- data/lib/pg_search/version.rb +1 -1
- data/pg_search.gemspec +8 -0
- data/spec/integration/pagination_spec.rb +36 -0
- data/spec/integration/pg_search_spec.rb +3 -3
- data/spec/lib/pg_search/configuration/column_spec.rb +29 -0
- data/spec/lib/pg_search/features/dmetaphone_spec.rb +51 -0
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +10 -10
- data/spec/lib/pg_search/multisearch_spec.rb +24 -24
- metadata +136 -11
- checksums.yaml +0 -7
    
        data/CHANGELOG.rdoc
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    | @@ -2,16 +2,9 @@ source "http://rubygems.org" | |
| 2 2 |  | 
| 3 3 | 
             
            gemspec
         | 
| 4 4 |  | 
| 5 | 
            -
            gem "rake"
         | 
| 6 | 
            -
            gem "rdoc"
         | 
| 7 | 
            -
            gem "pry"
         | 
| 8 | 
            -
             | 
| 9 5 | 
             
            gem 'pg', :platform => :ruby
         | 
| 10 6 | 
             
            gem "activerecord-jdbcpostgresql-adapter", :platform => :jruby
         | 
| 11 7 |  | 
| 12 | 
            -
            gem "rspec"
         | 
| 13 | 
            -
            gem "with_model"
         | 
| 14 | 
            -
             | 
| 15 8 | 
             
            gem "activerecord", ENV["ACTIVE_RECORD_VERSION"] if ENV["ACTIVE_RECORD_VERSION"]
         | 
| 16 9 |  | 
| 17 10 | 
             
            gem 'coveralls', :require => false, :platform => :mri_20
         | 
    
        data/lib/pg_search.rb
    CHANGED
    
    | @@ -1,6 +1,8 @@ | |
| 1 1 | 
             
            require "active_record"
         | 
| 2 2 | 
             
            require "active_support/concern"
         | 
| 3 3 | 
             
            require "active_support/core_ext/module/attribute_accessors"
         | 
| 4 | 
            +
            require "active_support/core_ext/string/strip"
         | 
| 5 | 
            +
            require "pg_search/extensions/arel"
         | 
| 4 6 |  | 
| 5 7 | 
             
            module PgSearch
         | 
| 6 8 | 
             
              autoload :Configuration, "pg_search/configuration"
         | 
| @@ -23,7 +23,7 @@ module PgSearch | |
| 23 23 | 
             
                  private
         | 
| 24 24 |  | 
| 25 25 | 
             
                  def table_name
         | 
| 26 | 
            -
                    @ | 
| 26 | 
            +
                    @model.quoted_table_name
         | 
| 27 27 | 
             
                  end
         | 
| 28 28 |  | 
| 29 29 | 
             
                  def column_name
         | 
| @@ -33,10 +33,6 @@ module PgSearch | |
| 33 33 | 
             
                  def expression
         | 
| 34 34 | 
             
                    full_name
         | 
| 35 35 | 
             
                  end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                  def alias
         | 
| 38 | 
            -
                    Configuration.alias(association.subselect_alias, @column_name)
         | 
| 39 | 
            -
                  end
         | 
| 40 36 | 
             
                end
         | 
| 41 37 | 
             
              end
         | 
| 42 38 | 
             
            end
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            require "arel/visitors/depth_first"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Workaround for https://github.com/Casecommons/pg_search/issues/101
         | 
| 4 | 
            +
            # Based on the solution from https://github.com/ernie/squeel/issues/122
         | 
| 5 | 
            +
            Arel::Visitors::DepthFirst.class_eval do
         | 
| 6 | 
            +
              unless method_defined?(:visit_Arel_Nodes_InfixOperation)
         | 
| 7 | 
            +
                alias :visit_Arel_Nodes_InfixOperation :binary
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
             | 
| @@ -26,8 +26,14 @@ module PgSearch | |
| 26 26 | 
             
                    end
         | 
| 27 27 |  | 
| 28 28 | 
             
                    def add_normalization(original_sql)
         | 
| 29 | 
            -
                      otherwise_normalized_sql =  | 
| 30 | 
            -
             | 
| 29 | 
            +
                      otherwise_normalized_sql = Arel.sql(
         | 
| 30 | 
            +
                        normalizer_to_wrap.add_normalization(original_sql)
         | 
| 31 | 
            +
                      )
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                      Arel::Nodes::NamedFunction.new(
         | 
| 34 | 
            +
                        "pg_search_dmetaphone",
         | 
| 35 | 
            +
                        [otherwise_normalized_sql]
         | 
| 36 | 
            +
                      ).to_sql
         | 
| 31 37 | 
             
                    end
         | 
| 32 38 |  | 
| 33 39 | 
             
                    private
         | 
| @@ -7,7 +7,7 @@ module PgSearch | |
| 7 7 | 
             
                    super
         | 
| 8 8 |  | 
| 9 9 | 
             
                    if options[:prefix] && model.connection.send(:postgresql_version) < 80400
         | 
| 10 | 
            -
                      raise PgSearch::NotSupportedForPostgresqlVersion.new(<<-MESSAGE. | 
| 10 | 
            +
                      raise PgSearch::NotSupportedForPostgresqlVersion.new(<<-MESSAGE.strip_heredoc)
         | 
| 11 11 | 
             
                        Sorry, {:using => {:tsearch => {:prefix => true}}} only works in PostgreSQL 8.4 and above.")
         | 
| 12 12 | 
             
                      MESSAGE
         | 
| 13 13 | 
             
                    end
         | 
| @@ -30,20 +30,19 @@ module PgSearch | |
| 30 30 | 
             
                  def tsquery_for_term(term)
         | 
| 31 31 | 
             
                    sanitized_term = term.gsub(DISALLOWED_TSQUERY_CHARACTERS, " ")
         | 
| 32 32 |  | 
| 33 | 
            -
                    term_sql = normalize(connection.quote(sanitized_term))
         | 
| 33 | 
            +
                    term_sql = Arel.sql(normalize(connection.quote(sanitized_term)))
         | 
| 34 34 |  | 
| 35 35 | 
             
                    # After this, the SQL expression evaluates to a string containing the term surrounded by single-quotes.
         | 
| 36 36 | 
             
                    # If :prefix is true, then the term will also have :* appended to the end.
         | 
| 37 | 
            -
                     | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
                       | 
| 41 | 
            -
             | 
| 42 | 
            -
                    ].compact.join(" || ")
         | 
| 37 | 
            +
                    terms = ["' ", term_sql, " '", (':*' if options[:prefix])].compact
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    tsquery_sql = terms.inject do |memo, term|
         | 
| 40 | 
            +
                      Arel::Nodes::InfixOperation.new("||", memo, term)
         | 
| 41 | 
            +
                    end
         | 
| 43 42 |  | 
| 44 43 | 
             
                    Arel::Nodes::NamedFunction.new(
         | 
| 45 44 | 
             
                      "to_tsquery",
         | 
| 46 | 
            -
                      [dictionary,  | 
| 45 | 
            +
                      [dictionary, tsquery_sql]
         | 
| 47 46 | 
             
                    ).to_sql
         | 
| 48 47 | 
             
                  end
         | 
| 49 48 |  | 
| @@ -28,17 +28,17 @@ module PgSearch | |
| 28 28 | 
             
                    model.connection
         | 
| 29 29 | 
             
                  end
         | 
| 30 30 |  | 
| 31 | 
            -
                  REBUILD_SQL_TEMPLATE = <<-SQL
         | 
| 32 | 
            -
            INSERT INTO :documents_table (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
            SQL
         | 
| 31 | 
            +
                  REBUILD_SQL_TEMPLATE = <<-SQL.strip_heredoc
         | 
| 32 | 
            +
                    INSERT INTO :documents_table (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 33 | 
            +
                      SELECT :model_name AS searchable_type,
         | 
| 34 | 
            +
                             :model_table.id AS searchable_id,
         | 
| 35 | 
            +
                             (
         | 
| 36 | 
            +
                               :content_expressions
         | 
| 37 | 
            +
                             ) AS content,
         | 
| 38 | 
            +
                             :current_time AS created_at,
         | 
| 39 | 
            +
                             :current_time AS updated_at
         | 
| 40 | 
            +
                      FROM :model_table
         | 
| 41 | 
            +
                  SQL
         | 
| 42 42 |  | 
| 43 43 | 
             
                  def rebuild_sql
         | 
| 44 44 | 
             
                    replacements.inject(REBUILD_SQL_TEMPLATE) do |sql, key|
         | 
    
        data/lib/pg_search/normalizer.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module PgSearch | |
| 8 8 | 
             
                  return sql_expression unless config.ignore.include?(:accents)
         | 
| 9 9 |  | 
| 10 10 | 
             
                  if config.postgresql_version < 90000
         | 
| 11 | 
            -
                    raise PgSearch::NotSupportedForPostgresqlVersion.new(<<-MESSAGE. | 
| 11 | 
            +
                    raise PgSearch::NotSupportedForPostgresqlVersion.new(<<-MESSAGE.strip_heredoc)
         | 
| 12 12 | 
             
                      Sorry, {:ignoring => :accents} only works in PostgreSQL 9.0 and above.
         | 
| 13 13 | 
             
                      #{config.inspect}
         | 
| 14 14 | 
             
                    MESSAGE
         | 
    
        data/lib/pg_search/tasks.rb
    CHANGED
    
    | @@ -5,9 +5,9 @@ namespace :pg_search do | |
| 5 5 | 
             
              namespace :multisearch do
         | 
| 6 6 | 
             
                desc "Rebuild PgSearch multisearch records for a given model"
         | 
| 7 7 | 
             
                task :rebuild, [:model,:schema] => :environment do |task, args|
         | 
| 8 | 
            -
                  raise ArgumentError, <<-MESSAGE unless args.model
         | 
| 9 | 
            -
            You must pass a model as an argument.
         | 
| 10 | 
            -
            Example: rake pg_search:multisearch:rebuild[BlogPost]
         | 
| 8 | 
            +
                  raise ArgumentError, <<-MESSAGE.strip_heredoc unless args.model
         | 
| 9 | 
            +
                    You must pass a model as an argument.
         | 
| 10 | 
            +
                    Example: rake pg_search:multisearch:rebuild[BlogPost]
         | 
| 11 11 | 
             
                  MESSAGE
         | 
| 12 12 | 
             
                  model_class = args.model.classify.constantize
         | 
| 13 13 | 
             
                  connection = PgSearch::Document.connection
         | 
    
        data/lib/pg_search/version.rb
    CHANGED
    
    
    
        data/pg_search.gemspec
    CHANGED
    
    | @@ -20,4 +20,12 @@ Gem::Specification.new do |s| | |
| 20 20 |  | 
| 21 21 | 
             
              s.add_dependency 'activerecord', '>=3.1'
         | 
| 22 22 | 
             
              s.add_dependency 'activesupport', '>=3.1'
         | 
| 23 | 
            +
              s.add_dependency 'arel'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              s.add_development_dependency 'rake'
         | 
| 26 | 
            +
              s.add_development_dependency 'rdoc'
         | 
| 27 | 
            +
              s.add_development_dependency 'pry'
         | 
| 28 | 
            +
              s.add_development_dependency 'rspec'
         | 
| 29 | 
            +
              s.add_development_dependency 'with_model'
         | 
| 30 | 
            +
              s.add_development_dependency 'will_paginate'
         | 
| 23 31 | 
             
            end
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "pagination" do
         | 
| 4 | 
            +
              describe "with will_paginate" do
         | 
| 5 | 
            +
                require 'will_paginate/active_record'
         | 
| 6 | 
            +
                with_model :PaginatedModel do
         | 
| 7 | 
            +
                  table do |t|
         | 
| 8 | 
            +
                    t.string :name
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  model do
         | 
| 12 | 
            +
                    include PgSearch
         | 
| 13 | 
            +
                    self.per_page = 2
         | 
| 14 | 
            +
                    pg_search_scope :search_name, :against => :name
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                it "is chainable before a search scope" do
         | 
| 19 | 
            +
                  better = PaginatedModel.create!(:name => "foo foo bar")
         | 
| 20 | 
            +
                  best = PaginatedModel.create!(:name => "foo foo foo")
         | 
| 21 | 
            +
                  good = PaginatedModel.create!(:name => "foo bar bar")
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  PaginatedModel.page(1).search_name("foo").should == [best, better]
         | 
| 24 | 
            +
                  PaginatedModel.page(2).search_name("foo").should == [good]
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                it "is chainable after a search scope" do
         | 
| 28 | 
            +
                  better = PaginatedModel.create!(:name => "foo foo bar")
         | 
| 29 | 
            +
                  best = PaginatedModel.create!(:name => "foo foo foo")
         | 
| 30 | 
            +
                  good = PaginatedModel.create!(:name => "foo bar bar")
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  PaginatedModel.search_name("foo").page(1).should == [best, better]
         | 
| 33 | 
            +
                  PaginatedModel.search_name("foo").page(2).should == [good]
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
| @@ -623,9 +623,9 @@ describe "an Active Record model which includes PgSearch" do | |
| 623 623 | 
             
                  let!(:unexpected) { ModelWithTsvector.create!(:content => 'longcat is looooooooong') }
         | 
| 624 624 |  | 
| 625 625 | 
             
                  before do
         | 
| 626 | 
            -
                    ActiveRecord::Base.connection.execute <<-SQL
         | 
| 627 | 
            -
                      UPDATE #{ModelWithTsvector. | 
| 628 | 
            -
                      SET content_tsvector = to_tsvector('english'::regconfig,  | 
| 626 | 
            +
                    ActiveRecord::Base.connection.execute <<-SQL.strip_heredoc
         | 
| 627 | 
            +
                      UPDATE #{ModelWithTsvector.quoted_table_name}
         | 
| 628 | 
            +
                      SET content_tsvector = to_tsvector('english'::regconfig, #{ModelWithTsvector.quoted_table_name}."content")
         | 
| 629 629 | 
             
                    SQL
         | 
| 630 630 |  | 
| 631 631 | 
             
                    ModelWithTsvector.pg_search_scope :search_by_content_with_tsvector,
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe PgSearch::Configuration::Column do
         | 
| 4 | 
            +
              describe "#full_name" do
         | 
| 5 | 
            +
                with_model :Model do
         | 
| 6 | 
            +
                  table do |t|
         | 
| 7 | 
            +
                    t.string :name
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it "returns the fully-qualified table and column name" do
         | 
| 12 | 
            +
                  column = described_class.new("name", nil, Model)
         | 
| 13 | 
            +
                  column.full_name.should == %Q{#{Model.quoted_table_name}."name"}
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              describe "#to_sql" do
         | 
| 18 | 
            +
                with_model :Model do
         | 
| 19 | 
            +
                  table do |t|
         | 
| 20 | 
            +
                    t.string :name
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                it "returns an expression that casts the column to text and coalesces it with an empty string" do
         | 
| 25 | 
            +
                  column = described_class.new("name", nil, Model)
         | 
| 26 | 
            +
                  column.to_sql.should == %Q{coalesce(#{Model.quoted_table_name}."name"::text, '')}
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe PgSearch::Features::DMetaphone do
         | 
| 4 | 
            +
              describe "#rank" do
         | 
| 5 | 
            +
                with_model :Model do
         | 
| 6 | 
            +
                  table do |t|
         | 
| 7 | 
            +
                    t.string :name
         | 
| 8 | 
            +
                    t.text :content
         | 
| 9 | 
            +
                  end
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                it "returns an expression similar to a TSearch, but wraps the arguments in pg_search_dmetaphone()" do
         | 
| 13 | 
            +
                  query = "query"
         | 
| 14 | 
            +
                  columns = [
         | 
| 15 | 
            +
                    PgSearch::Configuration::Column.new(:name, nil, Model),
         | 
| 16 | 
            +
                    PgSearch::Configuration::Column.new(:content, nil, Model),
         | 
| 17 | 
            +
                  ]
         | 
| 18 | 
            +
                  options = {}
         | 
| 19 | 
            +
                  config = stub(:config, :ignore => [])
         | 
| 20 | 
            +
                  normalizer = PgSearch::Normalizer.new(config)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  feature = described_class.new(query, options, columns, Model, normalizer)
         | 
| 23 | 
            +
                  feature.rank.to_sql.should ==
         | 
| 24 | 
            +
                    %Q{(ts_rank((to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."name"::text, ''))) || to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."content"::text, '')))), (to_tsquery('simple', ''' ' || pg_search_dmetaphone('query') || ' ''')), 0))}
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              describe "#conditions" do
         | 
| 29 | 
            +
                with_model :Model do
         | 
| 30 | 
            +
                  table do |t|
         | 
| 31 | 
            +
                    t.string :name
         | 
| 32 | 
            +
                    t.text :content
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                it "returns an expression similar to a TSearch, but wraps the arguments in pg_search_dmetaphone()" do
         | 
| 37 | 
            +
                  query = "query"
         | 
| 38 | 
            +
                  columns = [
         | 
| 39 | 
            +
                    PgSearch::Configuration::Column.new(:name, nil, Model),
         | 
| 40 | 
            +
                    PgSearch::Configuration::Column.new(:content, nil, Model),
         | 
| 41 | 
            +
                  ]
         | 
| 42 | 
            +
                  options = {}
         | 
| 43 | 
            +
                  config = stub(:config, :ignore => [])
         | 
| 44 | 
            +
                  normalizer = PgSearch::Normalizer.new(config)
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  feature = described_class.new(query, options, columns, Model, normalizer)
         | 
| 47 | 
            +
                  feature.conditions.to_sql.should ==
         | 
| 48 | 
            +
                    %Q{((to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."name"::text, ''))) || to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."content"::text, '')))) @@ (to_tsquery('simple', ''' ' || pg_search_dmetaphone('query') || ' ''')))}
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
            end
         | 
| @@ -84,16 +84,16 @@ describe PgSearch::Multisearch::Rebuilder do | |
| 84 84 | 
             
                      time = DateTime.parse("2001-01-01")
         | 
| 85 85 | 
             
                      rebuilder = PgSearch::Multisearch::Rebuilder.new(Model, lambda { time } )
         | 
| 86 86 |  | 
| 87 | 
            -
                      expected_sql = <<-SQL
         | 
| 88 | 
            -
            INSERT INTO "pg_search_documents" (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 87 | 
            +
                      expected_sql = <<-SQL.strip_heredoc
         | 
| 88 | 
            +
                        INSERT INTO "pg_search_documents" (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 89 | 
            +
                          SELECT 'Model' AS searchable_type,
         | 
| 90 | 
            +
                                 #{Model.quoted_table_name}.id AS searchable_id,
         | 
| 91 | 
            +
                                 (
         | 
| 92 | 
            +
                                   coalesce(#{Model.quoted_table_name}.name::text, '')
         | 
| 93 | 
            +
                                 ) AS content,
         | 
| 94 | 
            +
                                 '2001-01-01 00:00:00' AS created_at,
         | 
| 95 | 
            +
                                 '2001-01-01 00:00:00' AS updated_at
         | 
| 96 | 
            +
                          FROM #{Model.quoted_table_name}
         | 
| 97 97 | 
             
                      SQL
         | 
| 98 98 |  | 
| 99 99 | 
             
                      executed_sql = []
         | 
| @@ -31,7 +31,7 @@ describe PgSearch::Multisearch do | |
| 31 31 |  | 
| 32 32 | 
             
                describe "cleaning up search documents for this model" do
         | 
| 33 33 | 
             
                  before do
         | 
| 34 | 
            -
                    connection.execute <<-SQL
         | 
| 34 | 
            +
                    connection.execute <<-SQL.strip_heredoc
         | 
| 35 35 | 
             
                      INSERT INTO pg_search_documents
         | 
| 36 36 | 
             
                        (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 37 37 | 
             
                        VALUES
         | 
| @@ -74,7 +74,7 @@ describe PgSearch::Multisearch do | |
| 74 74 | 
             
                  context "when the model implements .rebuild_pg_search_documents" do
         | 
| 75 75 | 
             
                    before do
         | 
| 76 76 | 
             
                      def model.rebuild_pg_search_documents
         | 
| 77 | 
            -
                        connection.execute <<-SQL
         | 
| 77 | 
            +
                        connection.execute <<-SQL.strip_heredoc
         | 
| 78 78 | 
             
                          INSERT INTO pg_search_documents
         | 
| 79 79 | 
             
                            (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 80 80 | 
             
                            VALUES
         | 
| @@ -119,17 +119,17 @@ describe PgSearch::Multisearch do | |
| 119 119 | 
             
                    end
         | 
| 120 120 |  | 
| 121 121 | 
             
                    it "should generate the proper SQL code" do
         | 
| 122 | 
            -
                      expected_sql = <<-SQL
         | 
| 123 | 
            -
            INSERT INTO #{PgSearch::Document.quoted_table_name} (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 122 | 
            +
                      expected_sql = <<-SQL.strip_heredoc
         | 
| 123 | 
            +
                        INSERT INTO #{PgSearch::Document.quoted_table_name} (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 124 | 
            +
                          SELECT #{connection.quote(model.name)} AS searchable_type,
         | 
| 125 | 
            +
                                 #{model.quoted_table_name}.id AS searchable_id,
         | 
| 126 | 
            +
                                 (
         | 
| 127 | 
            +
                                   coalesce(#{model.quoted_table_name}.title::text, '')
         | 
| 128 | 
            +
                                 ) AS content,
         | 
| 129 | 
            +
                                 #{connection.quote(connection.quoted_date(now))} AS created_at,
         | 
| 130 | 
            +
                                 #{connection.quote(connection.quoted_date(now))} AS updated_at
         | 
| 131 | 
            +
                          FROM #{model.quoted_table_name}
         | 
| 132 | 
            +
                      SQL
         | 
| 133 133 |  | 
| 134 134 | 
             
                      statements = []
         | 
| 135 135 | 
             
                      connection.stub(:execute) { |sql| statements << sql }
         | 
| @@ -146,17 +146,17 @@ INSERT INTO #{PgSearch::Document.quoted_table_name} (searchable_type, searchable | |
| 146 146 | 
             
                    end
         | 
| 147 147 |  | 
| 148 148 | 
             
                    it "should generate the proper SQL code" do
         | 
| 149 | 
            -
                      expected_sql = <<-SQL
         | 
| 150 | 
            -
            INSERT INTO #{PgSearch::Document.quoted_table_name} (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
            SQL
         | 
| 149 | 
            +
                      expected_sql = <<-SQL.strip_heredoc
         | 
| 150 | 
            +
                        INSERT INTO #{PgSearch::Document.quoted_table_name} (searchable_type, searchable_id, content, created_at, updated_at)
         | 
| 151 | 
            +
                          SELECT #{connection.quote(model.name)} AS searchable_type,
         | 
| 152 | 
            +
                                 #{model.quoted_table_name}.id AS searchable_id,
         | 
| 153 | 
            +
                                 (
         | 
| 154 | 
            +
                                   coalesce(#{model.quoted_table_name}.title::text, '') || ' ' || coalesce(#{model.quoted_table_name}.content::text, '')
         | 
| 155 | 
            +
                                 ) AS content,
         | 
| 156 | 
            +
                                 #{connection.quote(connection.quoted_date(now))} AS created_at,
         | 
| 157 | 
            +
                                 #{connection.quote(connection.quoted_date(now))} AS updated_at
         | 
| 158 | 
            +
                          FROM #{model.quoted_table_name}
         | 
| 159 | 
            +
                      SQL
         | 
| 160 160 |  | 
| 161 161 | 
             
                      statements = []
         | 
| 162 162 | 
             
                      connection.stub(:execute) { |sql| statements << sql }
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,8 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pg_search
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 5 6 | 
             
            platform: ruby
         | 
| 6 7 | 
             
            authors:
         | 
| 7 8 | 
             
            - Grant Hutchins
         | 
| @@ -9,36 +10,152 @@ authors: | |
| 9 10 | 
             
            autorequire: 
         | 
| 10 11 | 
             
            bindir: bin
         | 
| 11 12 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013-04- | 
| 13 | 
            +
            date: 2013-04-08 00:00:00.000000000 Z
         | 
| 13 14 | 
             
            dependencies:
         | 
| 14 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 16 | 
             
              name: activerecord
         | 
| 16 17 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                none: false
         | 
| 17 19 | 
             
                requirements:
         | 
| 18 | 
            -
                - - '>='
         | 
| 20 | 
            +
                - - ! '>='
         | 
| 19 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 20 22 | 
             
                    version: '3.1'
         | 
| 21 23 | 
             
              type: :runtime
         | 
| 22 24 | 
             
              prerelease: false
         | 
| 23 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                none: false
         | 
| 24 27 | 
             
                requirements:
         | 
| 25 | 
            -
                - - '>='
         | 
| 28 | 
            +
                - - ! '>='
         | 
| 26 29 | 
             
                  - !ruby/object:Gem::Version
         | 
| 27 30 | 
             
                    version: '3.1'
         | 
| 28 31 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 29 32 | 
             
              name: activesupport
         | 
| 30 33 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 34 | 
            +
                none: false
         | 
| 31 35 | 
             
                requirements:
         | 
| 32 | 
            -
                - - '>='
         | 
| 36 | 
            +
                - - ! '>='
         | 
| 33 37 | 
             
                  - !ruby/object:Gem::Version
         | 
| 34 38 | 
             
                    version: '3.1'
         | 
| 35 39 | 
             
              type: :runtime
         | 
| 36 40 | 
             
              prerelease: false
         | 
| 37 41 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 42 | 
            +
                none: false
         | 
| 38 43 | 
             
                requirements:
         | 
| 39 | 
            -
                - - '>='
         | 
| 44 | 
            +
                - - ! '>='
         | 
| 40 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 41 46 | 
             
                    version: '3.1'
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: arel
         | 
| 49 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                none: false
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ! '>='
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
              type: :runtime
         | 
| 56 | 
            +
              prerelease: false
         | 
| 57 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                none: false
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - ! '>='
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: '0'
         | 
| 63 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 64 | 
            +
              name: rake
         | 
| 65 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                none: false
         | 
| 67 | 
            +
                requirements:
         | 
| 68 | 
            +
                - - ! '>='
         | 
| 69 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 70 | 
            +
                    version: '0'
         | 
| 71 | 
            +
              type: :development
         | 
| 72 | 
            +
              prerelease: false
         | 
| 73 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 74 | 
            +
                none: false
         | 
| 75 | 
            +
                requirements:
         | 
| 76 | 
            +
                - - ! '>='
         | 
| 77 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 78 | 
            +
                    version: '0'
         | 
| 79 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 80 | 
            +
              name: rdoc
         | 
| 81 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 82 | 
            +
                none: false
         | 
| 83 | 
            +
                requirements:
         | 
| 84 | 
            +
                - - ! '>='
         | 
| 85 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 86 | 
            +
                    version: '0'
         | 
| 87 | 
            +
              type: :development
         | 
| 88 | 
            +
              prerelease: false
         | 
| 89 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 90 | 
            +
                none: false
         | 
| 91 | 
            +
                requirements:
         | 
| 92 | 
            +
                - - ! '>='
         | 
| 93 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 94 | 
            +
                    version: '0'
         | 
| 95 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 96 | 
            +
              name: pry
         | 
| 97 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 98 | 
            +
                none: false
         | 
| 99 | 
            +
                requirements:
         | 
| 100 | 
            +
                - - ! '>='
         | 
| 101 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            +
                    version: '0'
         | 
| 103 | 
            +
              type: :development
         | 
| 104 | 
            +
              prerelease: false
         | 
| 105 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 106 | 
            +
                none: false
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ! '>='
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: rspec
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                none: false
         | 
| 115 | 
            +
                requirements:
         | 
| 116 | 
            +
                - - ! '>='
         | 
| 117 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 118 | 
            +
                    version: '0'
         | 
| 119 | 
            +
              type: :development
         | 
| 120 | 
            +
              prerelease: false
         | 
| 121 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 122 | 
            +
                none: false
         | 
| 123 | 
            +
                requirements:
         | 
| 124 | 
            +
                - - ! '>='
         | 
| 125 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 126 | 
            +
                    version: '0'
         | 
| 127 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 128 | 
            +
              name: with_model
         | 
| 129 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 130 | 
            +
                none: false
         | 
| 131 | 
            +
                requirements:
         | 
| 132 | 
            +
                - - ! '>='
         | 
| 133 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 134 | 
            +
                    version: '0'
         | 
| 135 | 
            +
              type: :development
         | 
| 136 | 
            +
              prerelease: false
         | 
| 137 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 138 | 
            +
                none: false
         | 
| 139 | 
            +
                requirements:
         | 
| 140 | 
            +
                - - ! '>='
         | 
| 141 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 142 | 
            +
                    version: '0'
         | 
| 143 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 144 | 
            +
              name: will_paginate
         | 
| 145 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 146 | 
            +
                none: false
         | 
| 147 | 
            +
                requirements:
         | 
| 148 | 
            +
                - - ! '>='
         | 
| 149 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 150 | 
            +
                    version: '0'
         | 
| 151 | 
            +
              type: :development
         | 
| 152 | 
            +
              prerelease: false
         | 
| 153 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 154 | 
            +
                none: false
         | 
| 155 | 
            +
                requirements:
         | 
| 156 | 
            +
                - - ! '>='
         | 
| 157 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 158 | 
            +
                    version: '0'
         | 
| 42 159 | 
             
            description: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
         | 
| 43 160 | 
             
              full text search
         | 
| 44 161 | 
             
            email:
         | 
| @@ -64,6 +181,7 @@ files: | |
| 64 181 | 
             
            - lib/pg_search/configuration/column.rb
         | 
| 65 182 | 
             
            - lib/pg_search/configuration/foreign_column.rb
         | 
| 66 183 | 
             
            - lib/pg_search/document.rb
         | 
| 184 | 
            +
            - lib/pg_search/extensions/arel.rb
         | 
| 67 185 | 
             
            - lib/pg_search/features.rb
         | 
| 68 186 | 
             
            - lib/pg_search/features/dmetaphone.rb
         | 
| 69 187 | 
             
            - lib/pg_search/features/feature.rb
         | 
| @@ -85,8 +203,11 @@ files: | |
| 85 203 | 
             
            - lib/pg_search/version.rb
         | 
| 86 204 | 
             
            - pg_search.gemspec
         | 
| 87 205 | 
             
            - spec/integration/associations_spec.rb
         | 
| 206 | 
            +
            - spec/integration/pagination_spec.rb
         | 
| 88 207 | 
             
            - spec/integration/pg_search_spec.rb
         | 
| 208 | 
            +
            - spec/lib/pg_search/configuration/column_spec.rb
         | 
| 89 209 | 
             
            - spec/lib/pg_search/document_spec.rb
         | 
| 210 | 
            +
            - spec/lib/pg_search/features/dmetaphone_spec.rb
         | 
| 90 211 | 
             
            - spec/lib/pg_search/features/trigram_spec.rb
         | 
| 91 212 | 
             
            - spec/lib/pg_search/features/tsearch_spec.rb
         | 
| 92 213 | 
             
            - spec/lib/pg_search/multisearch/rebuilder_spec.rb
         | 
| @@ -103,32 +224,36 @@ files: | |
| 103 224 | 
             
            homepage: https://github.com/Casecommons/pg_search
         | 
| 104 225 | 
             
            licenses:
         | 
| 105 226 | 
             
            - MIT
         | 
| 106 | 
            -
            metadata: {}
         | 
| 107 227 | 
             
            post_install_message: 
         | 
| 108 228 | 
             
            rdoc_options: []
         | 
| 109 229 | 
             
            require_paths:
         | 
| 110 230 | 
             
            - lib
         | 
| 111 231 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 232 | 
            +
              none: false
         | 
| 112 233 | 
             
              requirements:
         | 
| 113 | 
            -
              - - '>='
         | 
| 234 | 
            +
              - - ! '>='
         | 
| 114 235 | 
             
                - !ruby/object:Gem::Version
         | 
| 115 236 | 
             
                  version: '0'
         | 
| 116 237 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 238 | 
            +
              none: false
         | 
| 117 239 | 
             
              requirements:
         | 
| 118 | 
            -
              - - '>='
         | 
| 240 | 
            +
              - - ! '>='
         | 
| 119 241 | 
             
                - !ruby/object:Gem::Version
         | 
| 120 242 | 
             
                  version: '0'
         | 
| 121 243 | 
             
            requirements: []
         | 
| 122 244 | 
             
            rubyforge_project: 
         | 
| 123 | 
            -
            rubygems_version:  | 
| 245 | 
            +
            rubygems_version: 1.8.25
         | 
| 124 246 | 
             
            signing_key: 
         | 
| 125 | 
            -
            specification_version:  | 
| 247 | 
            +
            specification_version: 3
         | 
| 126 248 | 
             
            summary: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
         | 
| 127 249 | 
             
              full text search
         | 
| 128 250 | 
             
            test_files:
         | 
| 129 251 | 
             
            - spec/integration/associations_spec.rb
         | 
| 252 | 
            +
            - spec/integration/pagination_spec.rb
         | 
| 130 253 | 
             
            - spec/integration/pg_search_spec.rb
         | 
| 254 | 
            +
            - spec/lib/pg_search/configuration/column_spec.rb
         | 
| 131 255 | 
             
            - spec/lib/pg_search/document_spec.rb
         | 
| 256 | 
            +
            - spec/lib/pg_search/features/dmetaphone_spec.rb
         | 
| 132 257 | 
             
            - spec/lib/pg_search/features/trigram_spec.rb
         | 
| 133 258 | 
             
            - spec/lib/pg_search/features/tsearch_spec.rb
         | 
| 134 259 | 
             
            - spec/lib/pg_search/multisearch/rebuilder_spec.rb
         | 
    
        checksums.yaml
    DELETED
    
    | @@ -1,7 +0,0 @@ | |
| 1 | 
            -
            ---
         | 
| 2 | 
            -
            SHA1:
         | 
| 3 | 
            -
              metadata.gz: 953137586cb6148bd40249e053348adc9d1e4c4e
         | 
| 4 | 
            -
              data.tar.gz: bd82cbede7a515ea77280bb2667617abcbb3ba6a
         | 
| 5 | 
            -
            SHA512:
         | 
| 6 | 
            -
              metadata.gz: 4054d7eb7e376aee61ed698ccda4f8573752823e4b8de9e7bc192eefc84845aa2f3b0162f8de12704f5696367187bc1db2202f03c28aca1816128145e6aeebf9
         | 
| 7 | 
            -
              data.tar.gz: 3a2031283e5b9a8e80e19607dc1b6bf044c4bd9340febdc0fd6606dffeff9729be7a36e214dddd877a915e6ae02e61b9099aab4b6d972d8a43afd314fc218dd0
         |