ts_vector_tags 0.0.6 → 0.0.7
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/lib/ts_vector_tags.rb +7 -1
- data/spec/ts_vector_tags_spec.rb +2 -0
- data/ts_vector_tags.gemspec +1 -1
- metadata +3 -3
data/lib/ts_vector_tags.rb
CHANGED
@@ -34,7 +34,13 @@ module TsVectorTags
|
|
34
34
|
# Accepts a proper ts_query an allows complex logical expressions like "foo & !(bar | bling)"
|
35
35
|
scope :with_tags_query, lambda { |query|
|
36
36
|
raise InvalidTsQueryError, "Invalid tag query '#{query}'" unless TsVectorTags.acceptable_tsquery?(query)
|
37
|
-
|
37
|
+
# "!foo" will not match empty tsvectors, so we have to cheat using coalesce :-(
|
38
|
+
where("coalesce(tags_vector, '-invalid-tag-') @@ to_tsquery('simple', '#{query}')")
|
39
|
+
}
|
40
|
+
|
41
|
+
# Make sure empty vectors are always saved as null values
|
42
|
+
before_save lambda {
|
43
|
+
self.tags_vector = nil if self.tags_vector.strip.size == 0
|
38
44
|
}
|
39
45
|
end
|
40
46
|
end
|
data/spec/ts_vector_tags_spec.rb
CHANGED
data/ts_vector_tags.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ts_vector_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
segments:
|
77
77
|
- 0
|
78
|
-
hash: -
|
78
|
+
hash: -1217766814000727648
|
79
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
80
|
none: false
|
81
81
|
requirements:
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
segments:
|
86
86
|
- 0
|
87
|
-
hash: -
|
87
|
+
hash: -1217766814000727648
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project: ts_vector_tags
|
90
90
|
rubygems_version: 1.8.24
|