dynamoid_advanced_where 1.4.0 → 1.5.0

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: 77c5c86c6aeccd5d5cd9db4a6e030a3527d17c87776fb05de5a06966699a1167
4
- data.tar.gz: 02426eb629574d8bcd1ec7507c1f6795d0e3f22577ef54c21bf203351ccd81d3
3
+ metadata.gz: 1b7427e4321a6c8c50704320ff3912868bd50d3471dae090a26059c107f25210
4
+ data.tar.gz: e87fbb9ac716caefdc16bf3190b2cbd0075263dae6aff9e88154271717055691
5
5
  SHA512:
6
- metadata.gz: dcb79577e6f5e90cccb482e77d26614f7be1fe16bf265970441176fd794c0760107a994f444eabe9290151f5dfea9d8c263f359b663e7d5c87536a85540c38ac
7
- data.tar.gz: 5e736cf0adaa648c1b088ddb938ce8a41080df77e243fe8cb0cb70fb561ae985582e3002c9078eed4d2ebd3284cccee30c657d9f24806082520f0055c5b22849
6
+ metadata.gz: 33c0c156eef5278bc77f7679bf56762f23937e2dc949da35a4dd16b8c4d0e3fa4e4f20d864faaac9b0e4ec99a9befe56994d87287c96452570582b93921e649f
7
+ data.tar.gz: 1b0eab5b78254e4352d72d2930daf2aa1645b27e2759e87024387dd6efeaa9ed9bc70536e3fc0fd1c0fe0cdafcf4c2b22f8548672d0d3496ebb1c64687efe0ec
@@ -0,0 +1,21 @@
1
+ name: 'Lint'
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ run-rubocop:
7
+ name: Lint code
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ rubyVersion: ["2.7.6"]
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.rubyVersion }}
18
+ bundler-cache: true
19
+ cache-version: "${{ matrix.rubyVersion }}-0"
20
+ - name: Run RuboCop
21
+ run: bundle exec rubocop
@@ -0,0 +1,39 @@
1
+ name: Test
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ run-tests:
7
+ name: Test code
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby:
13
+ - 3.0.4
14
+ - 2.7.6
15
+ - 3.1.2
16
+ services:
17
+ dynamodb:
18
+ image: amazon/dynamodb-local
19
+ ports:
20
+ - 8000/tcp
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true
27
+ cache-version: ${{ matrix.ruby }}-0
28
+ - name: Run RSpec
29
+ env:
30
+ AWS_ACCESS_KEY_ID: asdf
31
+ AWS_SECRET_ACCESS_KEY: asdf
32
+ CI: true
33
+ DYNAMODB_HOST: http://localhost:${{job.services.dynamodb.ports[8000]}}/
34
+ run: bundle exec rspec
35
+ - name: Coveralls
36
+ uses: coverallsapp/github-action@v1.1.2
37
+ continue-on-error: true
38
+ with:
39
+ github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,5 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/GetTerminus/ruby_shared_configs/master/.rubocop.yml
3
+
4
+ Style/HashSyntax:
5
+ EnforcedShorthandSyntax: either
@@ -0,0 +1,91 @@
1
+ AllCops:
2
+ Exclude:
3
+ - Makefile
4
+ - vendor/**/*
5
+ - bin/**/*
6
+
7
+ Layout/EndOfLine:
8
+ Enabled: false
9
+
10
+ Style/DateTime:
11
+ Enabled: false
12
+
13
+ Style/Documentation:
14
+ Enabled: false
15
+
16
+ Lint/Debugger:
17
+ Enabled: true
18
+
19
+ Style/FrozenStringLiteralComment:
20
+ Enabled: true
21
+ EnforcedStyle: always
22
+
23
+ Style/TrailingCommaInHashLiteral:
24
+ Enabled: true
25
+ EnforcedStyleForMultiline: comma
26
+
27
+ Style/TrailingCommaInArrayLiteral:
28
+ Enabled: true
29
+ EnforcedStyleForMultiline: comma
30
+
31
+ Style/TrailingCommaInArguments:
32
+ Enabled: true
33
+ EnforcedStyleForMultiline: comma
34
+
35
+ Lint/UnusedMethodArgument:
36
+ AllowUnusedKeywordArguments: true
37
+
38
+ Layout/LineLength:
39
+ Enabled: true
40
+ Max: 280
41
+ IgnoreCopDirectives: true
42
+ AllowedPatterns: ['\A#', '\A\s*sig { .* }\Z']
43
+ Exclude:
44
+ - '**/*_pb.rb'
45
+
46
+ Metrics/AbcSize:
47
+ Enabled: true
48
+ Max: 48
49
+
50
+ Metrics/CyclomaticComplexity:
51
+ Max: 9
52
+
53
+ Metrics/MethodLength:
54
+ Enabled: true
55
+ Max: 32
56
+
57
+ Layout/ParameterAlignment:
58
+ Enabled: true
59
+ EnforcedStyle: with_fixed_indentation
60
+
61
+ Naming/MethodParameterName:
62
+ Enabled: true
63
+ AllowedNames: ['io', 'id', 'to', 'by', 'on', 'in', 'at', '_'] # Defaults + _
64
+
65
+ Layout/MultilineMethodCallIndentation:
66
+ Enabled: true
67
+ EnforcedStyle: indented
68
+
69
+ Style/ParallelAssignment:
70
+ Enabled: true
71
+
72
+ Metrics/ClassLength:
73
+ Max: 240
74
+
75
+ Metrics/BlockLength:
76
+ Max: 30
77
+ Exclude:
78
+ - spec/**/*.rb
79
+ - '**/*_pb.rb'
80
+
81
+ Metrics/ParameterLists:
82
+ Max: 6
83
+
84
+ Lint/AmbiguousBlockAssociation:
85
+ Exclude:
86
+ - spec/**/*.rb
87
+
88
+ Style/BlockDelimiters:
89
+ Enabled: true
90
+ Exclude:
91
+ - spec/**/*
data/.rubocop.yml CHANGED
@@ -1,3 +1,9 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+ - https://raw.githubusercontent.com/GetTerminus/ruby_shared_configs/master/.rubocop-3-1.yml
4
+
5
+
6
+
1
7
  AllCops:
2
8
  Exclude:
3
9
  - bin/*
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,42 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-10-31 20:09:20 UTC using RuboCop version 1.18.4.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'dynamoid_advanced_where.gemspec'
15
+
16
+ # Offense count: 6
17
+ Lint/MissingSuper:
18
+ Exclude:
19
+ - 'lib/dynamoid_advanced_where/nodes/and_node.rb'
20
+ - 'lib/dynamoid_advanced_where/nodes/exists_node.rb'
21
+ - 'lib/dynamoid_advanced_where/nodes/field_node.rb'
22
+ - 'lib/dynamoid_advanced_where/nodes/operation_node.rb'
23
+ - 'lib/dynamoid_advanced_where/nodes/or_node.rb'
24
+ - 'lib/dynamoid_advanced_where/nodes/root_node.rb'
25
+
26
+ # Offense count: 1
27
+ # Configuration parameters: AllowComments, AllowNil.
28
+ Lint/SuppressedException:
29
+ Exclude:
30
+ - 'lib/dynamoid_advanced_where/batched_updater.rb'
31
+
32
+ # Offense count: 1
33
+ Naming/AccessorMethodName:
34
+ Exclude:
35
+ - 'lib/dynamoid_advanced_where/batched_updater.rb'
36
+
37
+ # Offense count: 1
38
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
39
+ # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
40
+ Naming/MethodParameterName:
41
+ Exclude:
42
+ - 'lib/dynamoid_advanced_where/nodes/root_node.rb'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.0.4
data/Gemfile.lock CHANGED
@@ -1,105 +1,115 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamoid_advanced_where (1.4.0)
4
+ dynamoid_advanced_where (1.5.0)
5
5
  dynamoid (>= 3.2, < 4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.1.4)
11
- activesupport (= 6.1.4)
12
- activesupport (6.1.4)
10
+ activemodel (7.0.4)
11
+ activesupport (= 7.0.4)
12
+ activesupport (7.0.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
- zeitwerk (~> 2.3)
17
+ addressable (2.8.1)
18
+ public_suffix (>= 2.0.2, < 6.0)
18
19
  appraisal (2.4.1)
19
20
  bundler
20
21
  rake
21
22
  thor (>= 0.14.0)
22
23
  ast (2.4.2)
23
- aws-eventstream (1.1.1)
24
- aws-partitions (1.482.0)
25
- aws-sdk-core (3.119.0)
24
+ aws-eventstream (1.2.0)
25
+ aws-partitions (1.654.0)
26
+ aws-sdk-core (3.166.0)
26
27
  aws-eventstream (~> 1, >= 1.0.2)
27
- aws-partitions (~> 1, >= 1.239.0)
28
+ aws-partitions (~> 1, >= 1.651.0)
29
+ aws-sigv4 (~> 1.5)
30
+ jmespath (~> 1, >= 1.6.1)
31
+ aws-sdk-dynamodb (1.78.0)
32
+ aws-sdk-core (~> 3, >= 3.165.0)
28
33
  aws-sigv4 (~> 1.1)
29
- jmespath (~> 1.0)
30
- aws-sdk-dynamodb (1.62.0)
31
- aws-sdk-core (~> 3, >= 3.119.0)
32
- aws-sigv4 (~> 1.1)
33
- aws-sigv4 (1.2.4)
34
+ aws-sigv4 (1.5.2)
34
35
  aws-eventstream (~> 1, >= 1.0.2)
35
- bundler-audit (0.8.0)
36
+ bundler-audit (0.9.1)
36
37
  bundler (>= 1.2.0, < 3)
37
38
  thor (~> 1.0)
38
39
  childprocess (4.1.0)
39
40
  coderay (1.1.3)
40
41
  colorize (0.8.1)
41
- concurrent-ruby (1.1.9)
42
- diff-lcs (1.4.4)
42
+ concurrent-ruby (1.1.10)
43
+ crack (0.4.5)
44
+ rexml
45
+ diff-lcs (1.5.0)
43
46
  dynamoid (3.7.1)
44
47
  activemodel (>= 4)
45
48
  aws-sdk-dynamodb (~> 1.0)
46
49
  concurrent-ruby (>= 1.0)
47
- fasterer (0.9.0)
50
+ fasterer (0.10.0)
48
51
  colorize (~> 0.7)
49
- ruby_parser (>= 3.14.1)
50
- i18n (1.8.10)
52
+ ruby_parser (>= 3.19.1)
53
+ hashdiff (1.0.1)
54
+ i18n (1.12.0)
51
55
  concurrent-ruby (~> 1.0)
52
56
  iniparse (1.5.0)
53
- jmespath (1.4.0)
57
+ jmespath (1.6.1)
58
+ json (2.6.2)
54
59
  method_source (1.0.0)
55
- minitest (5.14.4)
56
- overcommit (0.58.0)
60
+ minitest (5.16.3)
61
+ overcommit (0.59.1)
57
62
  childprocess (>= 0.6.3, < 5)
58
63
  iniparse (~> 1.4)
59
64
  rexml (~> 3.2)
60
- parallel (1.20.1)
61
- parser (3.0.2.0)
65
+ parallel (1.22.1)
66
+ parser (3.1.2.1)
62
67
  ast (~> 2.4.1)
63
68
  pry (0.14.1)
64
69
  coderay (~> 1.1)
65
70
  method_source (~> 1.0)
66
- rainbow (3.0.0)
71
+ public_suffix (5.0.0)
72
+ rainbow (3.1.1)
67
73
  rake (10.5.0)
68
- regexp_parser (2.1.1)
74
+ regexp_parser (2.6.0)
69
75
  rexml (3.2.5)
70
- rspec (3.10.0)
71
- rspec-core (~> 3.10.0)
72
- rspec-expectations (~> 3.10.0)
73
- rspec-mocks (~> 3.10.0)
74
- rspec-core (3.10.1)
75
- rspec-support (~> 3.10.0)
76
- rspec-expectations (3.10.1)
76
+ rspec (3.12.0)
77
+ rspec-core (~> 3.12.0)
78
+ rspec-expectations (~> 3.12.0)
79
+ rspec-mocks (~> 3.12.0)
80
+ rspec-core (3.12.0)
81
+ rspec-support (~> 3.12.0)
82
+ rspec-expectations (3.12.0)
77
83
  diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.10.0)
79
- rspec-mocks (3.10.2)
84
+ rspec-support (~> 3.12.0)
85
+ rspec-mocks (3.12.0)
80
86
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.10.0)
82
- rspec-support (3.10.2)
83
- rubocop (1.18.4)
87
+ rspec-support (~> 3.12.0)
88
+ rspec-support (3.12.0)
89
+ rubocop (1.37.1)
90
+ json (~> 2.3)
84
91
  parallel (~> 1.10)
85
- parser (>= 3.0.0.0)
92
+ parser (>= 3.1.2.1)
86
93
  rainbow (>= 2.2.2, < 4.0)
87
94
  regexp_parser (>= 1.8, < 3.0)
88
- rexml
89
- rubocop-ast (>= 1.8.0, < 2.0)
95
+ rexml (>= 3.2.5, < 4.0)
96
+ rubocop-ast (>= 1.23.0, < 2.0)
90
97
  ruby-progressbar (~> 1.7)
91
98
  unicode-display_width (>= 1.4.0, < 3.0)
92
- rubocop-ast (1.8.0)
93
- parser (>= 3.0.1.1)
99
+ rubocop-ast (1.23.0)
100
+ parser (>= 3.1.1.0)
94
101
  ruby-progressbar (1.11.0)
95
- ruby_parser (3.16.0)
96
- sexp_processor (~> 4.15, >= 4.15.1)
97
- sexp_processor (4.15.3)
98
- thor (1.1.0)
99
- tzinfo (2.0.4)
102
+ ruby_parser (3.19.1)
103
+ sexp_processor (~> 4.16)
104
+ sexp_processor (4.16.1)
105
+ thor (1.2.1)
106
+ tzinfo (2.0.5)
100
107
  concurrent-ruby (~> 1.0)
101
- unicode-display_width (2.0.0)
102
- zeitwerk (2.4.2)
108
+ unicode-display_width (2.3.0)
109
+ webmock (3.18.1)
110
+ addressable (>= 2.8.0)
111
+ crack (>= 0.3.2)
112
+ hashdiff (>= 0.4.0, < 2.0.0)
103
113
 
104
114
  PLATFORMS
105
115
  ruby
@@ -117,6 +127,7 @@ DEPENDENCIES
117
127
  rake (~> 10.0)
118
128
  rspec (~> 3.0)
119
129
  rubocop
130
+ webmock
120
131
 
121
132
  BUNDLED WITH
122
- 2.1.4
133
+ 2.3.12
data/README.md CHANGED
@@ -114,6 +114,16 @@ Valid on field types: `string`, or `set/array` of `String` / `Integer`
114
114
  #### Example
115
115
  `where{|r| r.foo.includes?(123) }` and `where{|r| r.foo.includes?('foo') }`
116
116
 
117
+ ### In?
118
+ This operator may be used to check if:
119
+
120
+ * A string field is one of an enumerable set of values
121
+
122
+ Valid on field types: `string`
123
+
124
+ #### Example
125
+ `where{|r| r.foo.in?(['foo', 'bar']) }`
126
+
117
127
  ### Working with Map and Raw types
118
128
  When it comes to map and raw attribute types, DAW takes the approach of
119
129
  trusting you, since the exact format is not explicitly defined or enforced.
@@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency 'rake', '~> 10.0'
41
41
  spec.add_development_dependency 'rspec', '~> 3.0'
42
42
  spec.add_development_dependency 'rubocop'
43
+ spec.add_development_dependency 'webmock'
43
44
  end
@@ -22,8 +22,8 @@ module DynamoidAdvancedWhere
22
22
  return_values: 'ALL_NEW',
23
23
  key: {
24
24
  klass.hash_key => hash_key,
25
- klass.range_key => range_key
26
- }.delete_if { |k, _v| k.nil? }
25
+ klass.range_key => range_key,
26
+ }.delete_if { |k, _v| k.nil? },
27
27
  }
28
28
  resp = client.update_item(update_item_arguments.merge(key_args))
29
29
 
@@ -87,7 +87,7 @@ module DynamoidAdvancedWhere
87
87
  filter = merge_multiple_sets(
88
88
  [
89
89
  field_update_arguments,
90
- add_update_args
90
+ add_update_args,
91
91
  ],
92
92
  result_base: filter_builder.to_scan_filter,
93
93
  )
@@ -103,7 +103,7 @@ module DynamoidAdvancedWhere
103
103
 
104
104
  update_args.merge!(
105
105
  collected_update_expression: [
106
- "#{command} #{update_args[:collected_update_expression].join(', ')}"
106
+ "#{command} #{update_args[:collected_update_expression].join(', ')}",
107
107
  ]
108
108
  )
109
109
  end
@@ -114,7 +114,7 @@ module DynamoidAdvancedWhere
114
114
  [
115
115
  explicit_set_args,
116
116
  list_append_for_arrays,
117
- increment_field_updates
117
+ increment_field_updates,
118
118
  ]
119
119
  ),
120
120
  command: 'SET'
@@ -142,8 +142,8 @@ module DynamoidAdvancedWhere
142
142
  builder_hash = {
143
143
  collected_update_expression: [],
144
144
  expression_attribute_values: {
145
- ":#{zero_prefix}": 0
146
- }
145
+ ":#{zero_prefix}": 0,
146
+ },
147
147
  }
148
148
 
149
149
  _increments.each_with_object(builder_hash) do |(field, change), h|
@@ -169,8 +169,8 @@ module DynamoidAdvancedWhere
169
169
  builder_hash = {
170
170
  collected_update_expression: [],
171
171
  expression_attribute_values: {
172
- ":#{empty_list_prefix}": []
173
- }
172
+ ":#{empty_list_prefix}": [],
173
+ },
174
174
  }
175
175
 
176
176
  update_args = _array_appends.each_with_object(builder_hash) do |to_append, h|
@@ -205,9 +205,9 @@ module DynamoidAdvancedWhere
205
205
  {
206
206
  expression_attribute_names: Hash[update_target],
207
207
  expression_attribute_values: {
208
- ":#{prefix}" => dump(value, field_name)
209
- }
210
- }
208
+ ":#{prefix}" => dump(value, field_name),
209
+ },
210
+ },
211
211
  ]
212
212
  end
213
213
 
@@ -5,7 +5,7 @@ require_relative './nodes/null_node'
5
5
  module DynamoidAdvancedWhere
6
6
  class FilterBuilder
7
7
  VALID_COMPARETORS_FOR_RANGE_FILTER = [
8
- Nodes::GreaterThanNode
8
+ Nodes::GreaterThanNode,
9
9
  ].freeze
10
10
 
11
11
  attr_accessor :expression_node, :klass
@@ -18,13 +18,13 @@ module DynamoidAdvancedWhere
18
18
  def index_nodes
19
19
  [
20
20
  extract_query_filter_node,
21
- extract_range_key_node
21
+ extract_range_key_node,
22
22
  ].compact
23
23
  end
24
24
 
25
25
  def to_query_filter
26
26
  {
27
- key_condition_expression: key_condition_expression
27
+ key_condition_expression: key_condition_expression,
28
28
  }.merge!(expression_filters)
29
29
  end
30
30
 
@@ -41,21 +41,21 @@ module DynamoidAdvancedWhere
41
41
  def key_condition_expression
42
42
  @key_condition_expression ||= [
43
43
  extract_query_filter_node,
44
- extract_range_key_node
44
+ extract_range_key_node,
45
45
  ].compact.map(&:to_expression).join(' AND ')
46
46
  end
47
47
 
48
48
  def expression_attribute_names
49
49
  [
50
50
  expression_node,
51
- *index_nodes
51
+ *index_nodes,
52
52
  ].map(&:expression_attribute_names).inject({}, &:merge!)
53
53
  end
54
54
 
55
55
  def expression_attribute_values
56
56
  [
57
57
  expression_node,
58
- *index_nodes
58
+ *index_nodes,
59
59
  ].map(&:expression_attribute_values).inject({}, &:merge!)
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ module DynamoidAdvancedWhere
63
63
  {
64
64
  filter_expression: expression_node.to_expression,
65
65
  expression_attribute_names: expression_attribute_names,
66
- expression_attribute_values: expression_attribute_values
66
+ expression_attribute_values: expression_attribute_values,
67
67
  }.delete_if { |_, v| v.nil? || v.empty? }
68
68
  end
69
69
 
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module DynamoidAdvancedWhere
6
+ module Nodes
7
+ class ArrayLiteralNode
8
+ attr_accessor :value, :attr_prefix
9
+
10
+ def initialize(value)
11
+ self.value = value
12
+ self.attr_prefix = SecureRandom.hex
13
+ freeze
14
+ end
15
+
16
+ def to_expression
17
+ values = value.each_with_index.map do |_, idx|
18
+ ":#{attr_prefix}#{idx}"
19
+ end
20
+ "(#{values.join(', ')})"
21
+ end
22
+
23
+ def expression_attribute_names
24
+ {}
25
+ end
26
+
27
+ def expression_attribute_values
28
+ value.each_with_index.map do |val, idx|
29
+ [":#{attr_prefix}#{idx}", val]
30
+ end.to_h
31
+ end
32
+ end
33
+ end
34
+ end
@@ -30,7 +30,7 @@ module DynamoidAdvancedWhere
30
30
 
31
31
  def expression_attribute_values
32
32
  {
33
- ":#{prefix}" => nil
33
+ ":#{prefix}" => nil,
34
34
  }
35
35
  end
36
36
  end
@@ -4,6 +4,7 @@ require_relative './equality_node'
4
4
  require_relative './greater_than_node'
5
5
  require_relative './exists_node'
6
6
  require_relative './includes'
7
+ require_relative './in_node'
7
8
  require_relative './subfield'
8
9
 
9
10
  module DynamoidAdvancedWhere
@@ -60,6 +61,7 @@ module DynamoidAdvancedWhere
60
61
 
61
62
  class StringAttributeNode < FieldNode
62
63
  include Concerns::SupportsIncludes
64
+ include Concerns::SupportsIn
63
65
  end
64
66
 
65
67
  class NativeBooleanAttributeNode < FieldNode; end
@@ -74,13 +76,11 @@ module DynamoidAdvancedWhere
74
76
  include Concerns::SupportsGreaterThan
75
77
 
76
78
  ALLOWED_COMPARISON_TYPES = [
77
- Numeric
79
+ Numeric,
78
80
  ].freeze
79
81
 
80
82
  def parse_right_hand_side(val)
81
- unless ALLOWED_COMPARISON_TYPES.detect { |k| val.is_a?(k) }
82
- raise ArgumentError, "unable to compare number to `#{val.class}`"
83
- end
83
+ raise ArgumentError, "unable to compare number to `#{val.class}`" unless ALLOWED_COMPARISON_TYPES.detect { |k| val.is_a?(k) }
84
84
 
85
85
  val
86
86
  end
@@ -166,6 +166,7 @@ module DynamoidAdvancedWhere
166
166
  FIELD_MAPPING = {
167
167
  { type: :string } => StringAttributeNode,
168
168
  { type: :number } => NumberAttributeNode,
169
+ { type: :integer } => NumberAttributeNode,
169
170
 
170
171
  # Boolean Fields
171
172
  { type: :boolean, store_as_native_boolean: true } =>
@@ -199,7 +200,7 @@ module DynamoidAdvancedWhere
199
200
  { type: :raw } => RawAttributeNode,
200
201
 
201
202
  # Custom Object
202
- ->(c) { c[:type].is_a?(Class) } => CustomClassAttributeNode
203
+ ->(c) { c[:type].is_a?(Class) } => CustomClassAttributeNode,
203
204
  }.freeze
204
205
  end
205
206
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DynamoidAdvancedWhere
4
+ module Nodes
5
+ class InNode < OperationNode
6
+ def to_expression
7
+ "#{lh_operation.to_expression} IN #{rh_operation.to_expression}"
8
+ end
9
+ end
10
+
11
+ module Concerns
12
+ module SupportsIn
13
+ def in?(other_value)
14
+ val = if respond_to?(:parse_right_hand_side)
15
+ parse_right_hand_side(other_value)
16
+ else
17
+ other_value
18
+ end
19
+
20
+ raise 'Expected parameter of `in?` to be an array' unless val.is_a?(Array)
21
+
22
+ InNode.new(
23
+ lh_operation: self,
24
+ rh_operation: ArrayLiteralNode.new(val)
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -3,6 +3,7 @@
3
3
  require_relative './nodes/base_node'
4
4
  require_relative './nodes/field_node'
5
5
  require_relative './nodes/literal_node'
6
+ require_relative './nodes/array_literal_node'
6
7
  require_relative './nodes/operation_node'
7
8
  require_relative './nodes/root_node'
8
9
  require_relative './nodes/and_node'
@@ -67,7 +67,7 @@ module DynamoidAdvancedWhere
67
67
  self.class.new(**{
68
68
  klass: klass,
69
69
  start_hash: start_hash,
70
- root_node: root_node
70
+ root_node: root_node,
71
71
  }.merge(changes))
72
72
  end
73
73
  end
@@ -48,7 +48,7 @@ module DynamoidAdvancedWhere
48
48
 
49
49
  def each_page_via_query
50
50
  query = {
51
- table_name: table_name
51
+ table_name: table_name,
52
52
  }.merge(filter_builder.to_query_filter)
53
53
 
54
54
  query[:limit] = query_builder.record_limit if query_builder.record_limit
@@ -76,7 +76,7 @@ module DynamoidAdvancedWhere
76
76
 
77
77
  def each_page_via_scan
78
78
  query = {
79
- table_name: table_name
79
+ table_name: table_name,
80
80
  }.merge(filter_builder.to_scan_filter)
81
81
 
82
82
  query[:limit] = query_builder.record_limit if query_builder.record_limit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamoidAdvancedWhere
4
- VERSION = '1.4.0'
4
+ VERSION = '1.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamoid_advanced_where
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Malinconico
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-06 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynamoid
@@ -142,6 +142,20 @@ dependencies:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: webmock
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
145
159
  description: things
146
160
  email:
147
161
  - bmalinconico@terminus.com
@@ -149,10 +163,14 @@ executables: []
149
163
  extensions: []
150
164
  extra_rdoc_files: []
151
165
  files:
152
- - ".circleci/config.yml"
166
+ - ".github/workflows/lint.yml"
167
+ - ".github/workflows/test.yml"
153
168
  - ".gitignore"
154
169
  - ".rspec"
170
+ - ".rubocop-https---raw-githubusercontent-com-GetTerminus-ruby-shared-configs-master--rubocop-3-1-yml"
171
+ - ".rubocop-https---raw-githubusercontent-com-GetTerminus-ruby-shared-configs-master--rubocop-yml"
155
172
  - ".rubocop.yml"
173
+ - ".rubocop_todo.yml"
156
174
  - ".ruby-version"
157
175
  - ".travis.yml"
158
176
  - Appraisals
@@ -180,11 +198,13 @@ files:
180
198
  - lib/dynamoid_advanced_where/integrations/model.rb
181
199
  - lib/dynamoid_advanced_where/nodes.rb
182
200
  - lib/dynamoid_advanced_where/nodes/and_node.rb
201
+ - lib/dynamoid_advanced_where/nodes/array_literal_node.rb
183
202
  - lib/dynamoid_advanced_where/nodes/base_node.rb
184
203
  - lib/dynamoid_advanced_where/nodes/equality_node.rb
185
204
  - lib/dynamoid_advanced_where/nodes/exists_node.rb
186
205
  - lib/dynamoid_advanced_where/nodes/field_node.rb
187
206
  - lib/dynamoid_advanced_where/nodes/greater_than_node.rb
207
+ - lib/dynamoid_advanced_where/nodes/in_node.rb
188
208
  - lib/dynamoid_advanced_where/nodes/includes.rb
189
209
  - lib/dynamoid_advanced_where/nodes/less_than_node.rb
190
210
  - lib/dynamoid_advanced_where/nodes/literal_node.rb
@@ -197,10 +217,10 @@ files:
197
217
  - lib/dynamoid_advanced_where/query_builder.rb
198
218
  - lib/dynamoid_advanced_where/query_materializer.rb
199
219
  - lib/dynamoid_advanced_where/version.rb
200
- homepage:
220
+ homepage:
201
221
  licenses: []
202
222
  metadata: {}
203
- post_install_message:
223
+ post_install_message:
204
224
  rdoc_options: []
205
225
  require_paths:
206
226
  - lib
@@ -215,8 +235,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
235
  - !ruby/object:Gem::Version
216
236
  version: '0'
217
237
  requirements: []
218
- rubygems_version: 3.1.2
219
- signing_key:
238
+ rubygems_version: 3.2.33
239
+ signing_key:
220
240
  specification_version: 4
221
241
  summary: things
222
242
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,129 +0,0 @@
1
- version: 2.0
2
-
3
- workflows:
4
- version: 2
5
- build:
6
- jobs:
7
- - "ruby-2.5"
8
- - "ruby-2.6"
9
- - "ruby-2.7"
10
- - "ruby-3.0"
11
-
12
- jobs:
13
- "ruby-3.0":
14
- docker:
15
- - image: ruby:2.5
16
- - image: amazon/dynamodb-local
17
- environment:
18
- MAX_HEAP_SIZE: 1024m
19
- HEAP_NEWSIZE: 512m
20
-
21
- steps:
22
- - checkout
23
- - restore_cache:
24
- keys:
25
- - v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
26
- # fallback to using the latest cache if no exact match is found
27
- - v1-dependencies-
28
-
29
- - run:
30
- name: install dependencies
31
- command: |
32
- gem update bundler
33
- bundle install
34
- bundle exec appraisal install
35
- - save_cache:
36
- paths:
37
- - ./vendor/bundle
38
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
39
- - run: bundle exec appraisal rspec --format progress
40
-
41
- "ruby-2.5":
42
- docker:
43
- - image: ruby:2.5
44
- - image: amazon/dynamodb-local
45
- environment:
46
- MAX_HEAP_SIZE: 1024m
47
- HEAP_NEWSIZE: 512m
48
-
49
- steps:
50
- - checkout
51
- - restore_cache:
52
- keys:
53
- - v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
54
- # fallback to using the latest cache if no exact match is found
55
- - v1-dependencies-
56
-
57
- - run:
58
- name: install dependencies
59
- command: |
60
- gem update bundler
61
- bundle install
62
- bundle exec appraisal install
63
- - save_cache:
64
- paths:
65
- - ./vendor/bundle
66
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
67
- - run: bundle exec appraisal rspec --format progress
68
-
69
- "ruby-2.6":
70
- docker:
71
- - image: ruby:2.6
72
- - image: amazon/dynamodb-local
73
- environment:
74
- MAX_HEAP_SIZE: 1024m
75
- HEAP_NEWSIZE: 512m
76
-
77
- steps:
78
- - checkout
79
- - restore_cache:
80
- keys:
81
- - v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
82
- # fallback to using the latest cache if no exact match is found
83
- - v1-dependencies-
84
-
85
- - run:
86
- name: install dependencies
87
- command: |
88
- gem update bundler
89
- bundle install
90
- bundle exec appraisal install
91
- - save_cache:
92
- paths:
93
- - ./vendor/bundle
94
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
95
- - run: bundle exec appraisal rspec --format progress
96
-
97
- "ruby-2.7":
98
- docker:
99
- - image: ruby:2.7
100
- - image: amazon/dynamodb-local
101
- environment:
102
- MAX_HEAP_SIZE: 1024m
103
- HEAP_NEWSIZE: 512m
104
-
105
- steps:
106
- - checkout
107
- - restore_cache:
108
- keys:
109
- - v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
110
- # fallback to using the latest cache if no exact match is found
111
- - v1-dependencies-
112
-
113
- - run:
114
- name: install dependencies
115
- command: |
116
- gem update bundler
117
- bundle install
118
- bundle exec appraisal install
119
- - save_cache:
120
- paths:
121
- - ./vendor/bundle
122
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "Appraisals" }}
123
- - run: bundle exec appraisal rspec --format progress
124
-
125
-
126
-
127
-
128
-
129
-