tag_columns 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76c6ce1985882f48d00cd3120f5364f66d253a491f885c4a35803c1289e79af3
4
- data.tar.gz: 01454b2b479b28064e9904f80c89da5ddbd5c99515de50a8f5fa1d1faf3f1f0d
3
+ metadata.gz: 2f2da2f8b26c73aa0c1694483cbd928b362771462c38660e0f97ac23eea636cd
4
+ data.tar.gz: 6dd4f9e84216e504ffe753d2f408458be29dbb2cde2464841fc859d744654e47
5
5
  SHA512:
6
- metadata.gz: cc896caf28cc640b4a90511808ceb7f55c2b78383ec5121b392970990a31d4232aa49097a9f6daf887f231b87b033a7ffc92d8919c00a0e97bc7f51bb9cb544e
7
- data.tar.gz: baa4821466bada3737e7bad0853ae9e1664621aff742475915bab595d63cec50db26264de6dcc2db291352dbf144150ac6b9f99f1e032597bf786dbf3fdeb0aa
6
+ metadata.gz: a42f325d2d7d2248b4c509d19182adfc1e78abd91bdde7cf4c77e918c79d07bdcdc6faee78e32fd64208d2099be263a87c3de92b032609b8f12a7dbe0842f1aa
7
+ data.tar.gz: 2cf4f50c56ee9d718b521a1df50c9798e23556bbcd0b107ee6119240ba2c32f29f336c5ac0bbd1fd18c65565e6e234c808a9a3a0b31b1aa59e5614de96cae5cc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tag_columns (0.1.7)
4
+ tag_columns (0.1.8)
5
5
  activesupport
6
6
 
7
7
  GEM
data/lib/tag_columns.rb CHANGED
@@ -56,8 +56,21 @@ module TagColumns
56
56
  where contains
57
57
  }
58
58
 
59
- scope :"without_any_#{method_name}", ->(*tags) { where.not id: public_send(:"with_any_#{method_name}", *tags) }
60
- scope :"without_all_#{method_name}", ->(*tags) { where.not id: public_send(:"with_all_#{method_name}", *tags) }
59
+ scope :"without_any_#{method_name}", ->(*tags) {
60
+ column_cast = Arel::Nodes::NamedFunction.new("CAST", [arel_table[column_name].as("text[]")])
61
+ value = Arel::Nodes::SqlLiteral.new(sanitize_sql_array(["ARRAY[?]", tag_columns_sanitize_list(tags)]))
62
+ value_cast = Arel::Nodes::NamedFunction.new("CAST", [value.as("text[]")])
63
+ overlap = Arel::Nodes::InfixOperation.new("&&", column_cast, value_cast)
64
+ where.not overlap
65
+ }
66
+
67
+ scope :"without_all_#{method_name}", ->(*tags) {
68
+ column_cast = Arel::Nodes::NamedFunction.new("CAST", [arel_table[column_name].as("text[]")])
69
+ value = Arel::Nodes::SqlLiteral.new(sanitize_sql_array(["ARRAY[?]", tag_columns_sanitize_list(tags)]))
70
+ value_cast = Arel::Nodes::NamedFunction.new("CAST", [value.as("text[]")])
71
+ contains = Arel::Nodes::InfixOperation.new("@>", column_cast, value_cast)
72
+ where.not contains
73
+ }
61
74
 
62
75
  before_validation -> { self[column_name] = self.class.tag_columns_sanitize_list(self[column_name]) }
63
76
 
@@ -1,3 +1,3 @@
1
1
  module TagColumns
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tag_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-11 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport