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.
@@ -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
- where("tags_vector @@ to_tsquery('simple', '#{query}')")
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
@@ -22,6 +22,8 @@ end
22
22
  class Thing
23
23
  def self.scope(name, options = {}); end
24
24
 
25
+ def self.before_save(*args); end
26
+
25
27
  attr_accessor :tags_vector
26
28
  include TsVectorTags
27
29
 
@@ -2,7 +2,7 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  module TsVectorTags
5
- VERSION = "0.0.6"
5
+ VERSION = "0.0.7"
6
6
  end
7
7
 
8
8
  Gem::Specification.new do |s|
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.6
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: -2976820661742119530
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: -2976820661742119530
87
+ hash: -1217766814000727648
88
88
  requirements: []
89
89
  rubyforge_project: ts_vector_tags
90
90
  rubygems_version: 1.8.24