where_any 0.1.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8720b83377ca8b8f8b55981a951157a5d800e4029fc61ec0786036e47915c841
4
- data.tar.gz: 8c7db28c73611593239ba7385d8b51be63e3c8ff5da25392db8e323276a67e99
3
+ metadata.gz: 9757fc6639c9875f9ab31bcae335740807d9c9f63fe0765dea00b2775080efa3
4
+ data.tar.gz: 94089af17bba4a0b175b9cf23ce6d033eae826aa6c74f6f8086a891a3ed3359a
5
5
  SHA512:
6
- metadata.gz: f112f2ba41d11a6db21f6636eb820bf2731a2b8691cf232d2389ce4d73b9a4094a6d6749538f47cd553a96d9c1fd8b6878ca86343341d08deb673ed208760a28
7
- data.tar.gz: '03830003bbeb718a747906b12d718780c74b9aa0c1e2be07c6a96013f0265dd47cbcf8e0acab852d5b971bf7db92c39e4f0a76218f03d1c507d8496f50edb8aa'
6
+ metadata.gz: 36d5778b3983606cda22f424715bfbfc324619fe275730571274a26aef99459cbffefa8994784ac1f5b97be1537cedcf357aae216eb5d0256fd895cc65950c1d
7
+ data.tar.gz: a5618216ea0d08d3e6a108bc3f8a78868ab6ecde769e7a32ee2d54503d92f3179dd2200cb1d17ab2857c79289296f1154ea5d8eeca9746e83b5df562ba880242
data/Gemfile.lock CHANGED
@@ -1,29 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- where_any (0.1.0)
4
+ where_any (0.1.1)
5
5
  activerecord (>= 5.2.0, < 8)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.1.4.1)
11
- activesupport (= 6.1.4.1)
12
- activerecord (6.1.4.1)
13
- activemodel (= 6.1.4.1)
14
- activesupport (= 6.1.4.1)
15
- activesupport (6.1.4.1)
10
+ activemodel (7.0.4)
11
+ activesupport (= 7.0.4)
12
+ activerecord (7.0.4)
13
+ activemodel (= 7.0.4)
14
+ activesupport (= 7.0.4)
15
+ activesupport (7.0.4)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
21
20
  ast (2.4.2)
22
- concurrent-ruby (1.1.9)
21
+ concurrent-ruby (1.1.10)
23
22
  diff-lcs (1.4.4)
24
- i18n (1.8.11)
23
+ i18n (1.12.0)
25
24
  concurrent-ruby (~> 1.0)
26
- minitest (5.14.4)
25
+ minitest (5.16.3)
27
26
  parallel (1.21.0)
28
27
  parser (3.0.3.2)
29
28
  ast (~> 2.4.1)
@@ -58,10 +57,9 @@ GEM
58
57
  rubocop-rspec (2.6.0)
59
58
  rubocop (~> 1.19)
60
59
  ruby-progressbar (1.11.0)
61
- tzinfo (2.0.4)
60
+ tzinfo (2.0.5)
62
61
  concurrent-ruby (~> 1.0)
63
62
  unicode-display_width (2.1.0)
64
- zeitwerk (2.5.1)
65
63
 
66
64
  PLATFORMS
67
65
  x86_64-linux
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhereAny
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/where_any.rb CHANGED
@@ -3,6 +3,19 @@
3
3
  require_relative 'where_any/version'
4
4
 
5
5
  module WhereAny
6
+ # @param name [String]
7
+ # @return [ActiveRecord::Type::Value]
8
+ def array_type_for_attribute(name)
9
+ element_type = type_for_attribute(name)
10
+
11
+ if (type = element_type.type)
12
+ ActiveRecord::Type.lookup(type, array: true)
13
+ else
14
+ # For unknown types (e.g. from projected columns), use a generic array type.
15
+ ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array.new(element_type)
16
+ end
17
+ end
18
+
6
19
  # @param name [String]
7
20
  # @param value [Object]
8
21
  # @return [Arel::Nodes::Node]
@@ -17,8 +30,7 @@ module WhereAny
17
30
  # @param value [Object]
18
31
  # @return [Arel::Nodes::Node]
19
32
  def bind_array(name, value)
20
- element_type = type_for_attribute(name)
21
- attribute_type = ActiveRecord::Type.lookup(element_type.type, array: true)
33
+ attribute_type = array_type_for_attribute(name)
22
34
  query_attribute = ActiveRecord::Relation::QueryAttribute.new(name.to_s, value, attribute_type)
23
35
 
24
36
  Arel::Nodes::BindParam.new(query_attribute)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: where_any
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minty Fresh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.2.15
77
+ rubygems_version: 3.3.7
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Postgres ANY() and ALL() expressions for ActiveRecord.