pg_search 0.1 → 0.1.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/.gitignore +2 -1
- data/CHANGELOG +5 -0
- data/Rakefile +1 -1
- data/TODO +4 -6
- data/gemfiles/Gemfile.common +1 -1
- data/lib/pg_search/features/tsearch.rb +1 -1
- data/lib/pg_search/version.rb +1 -1
- data/spec/pg_search_spec.rb +11 -0
- metadata +4 -3
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ task :default => :spec
|
|
6
6
|
environments = %w[rails2 rails3]
|
7
7
|
|
8
8
|
in_environment = lambda do |environment, command|
|
9
|
-
sh %Q{export BUNDLE_GEMFILE="gemfiles/#{environment}/Gemfile"; bundle
|
9
|
+
sh %Q{export BUNDLE_GEMFILE="gemfiles/#{environment}/Gemfile"; bundle update && bundle exec #{command}}
|
10
10
|
end
|
11
11
|
|
12
12
|
in_all_environments = lambda do |command|
|
data/TODO
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
* Railtie for rake tasks
|
2
|
-
* README
|
3
2
|
* Tracker project
|
4
|
-
* Mailing list
|
5
|
-
* License
|
6
|
-
* Publish gem
|
7
3
|
* Exceptions for missing trigram, dmetaphone, etc. support
|
8
4
|
* LIKE search
|
9
|
-
* ability to specify multiple ranks: :ranked_by => [:tsearch, :trigram]
|
10
|
-
* ability to mix ranks together with weights: :ranked_by => {:tsearch => 1.0, :trigram => 0.5}
|
11
5
|
* accept a block and pass it to the underlying scope
|
12
6
|
* ability to search again a tsvector column
|
7
|
+
* Generate indexes
|
8
|
+
* Allow for chaining multiple pg_search scopes
|
9
|
+
|
10
|
+
Also see https://github.com/Casecommons/pg_search/issues
|
data/gemfiles/Gemfile.common
CHANGED
@@ -40,7 +40,7 @@ module PgSearch
|
|
40
40
|
term_sql = @normalizer.add_normalization(connection.quote(sanitized_term))
|
41
41
|
|
42
42
|
# After this, the SQL expression evaluates to a string containing the term surrounded by single-quotes.
|
43
|
-
tsquery_sql = "#{connection.quote("'")} || #{term_sql} || #{connection.quote("'")}"
|
43
|
+
tsquery_sql = "#{connection.quote("' ")} || #{term_sql} || #{connection.quote(" '")}"
|
44
44
|
|
45
45
|
# Add tsearch prefix operator if we're using a prefix search.
|
46
46
|
tsquery_sql = "#{tsquery_sql} || #{connection.quote(':*')}" if @options[:prefix]
|
data/lib/pg_search/version.rb
CHANGED
data/spec/pg_search_spec.rb
CHANGED
@@ -246,6 +246,7 @@ describe "an ActiveRecord model which includes PgSearch" do
|
|
246
246
|
results = model_with_pg_search.search_content("foo bar .,?() \\")
|
247
247
|
results.should == [included]
|
248
248
|
end
|
249
|
+
|
249
250
|
it "accepts non-string queries and calls #to_s on them" do
|
250
251
|
foo = model_with_pg_search.create!(:content => "foo")
|
251
252
|
not_a_string = stub(:to_s => "foo")
|
@@ -456,6 +457,16 @@ describe "an ActiveRecord model which includes PgSearch" do
|
|
456
457
|
results = model_with_pg_search.with_dmetaphones('Wight')
|
457
458
|
results.should == [included]
|
458
459
|
end
|
460
|
+
|
461
|
+
it "can handle terms that do not have a dmetaphone equivalent" do
|
462
|
+
term_with_blank_metaphone = "w"
|
463
|
+
|
464
|
+
included = model_with_pg_search.create!(:title => 'White', :content => nil)
|
465
|
+
excluded = model_with_pg_search.create!(:title => 'Black', :content => nil)
|
466
|
+
|
467
|
+
results = model_with_pg_search.with_dmetaphones('Wight W')
|
468
|
+
results.should == [included]
|
469
|
+
end
|
459
470
|
end
|
460
471
|
|
461
472
|
context "using multiple features" do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Case Commons, LLC
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-20 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|