dynamoid_advanced_where 1.7.1 → 1.8.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: 1a85cd45266e1210f64c5d4bd1187416c2643aeb5de64d66c9f9ad9fbd4ba456
4
- data.tar.gz: ab0281d70cdc10879af23d28e9fefac40679e3c28da55d19244b828718c30d5a
3
+ metadata.gz: 65c24edd4faee3078a0e07e8ae9fb25ed11e4a5e4902c4f1bb450c8f52b06ce2
4
+ data.tar.gz: d4cc130e24982769928c7b5e0bd43c1c0bf548423a3117d5f31e8dbbc956eb68
5
5
  SHA512:
6
- metadata.gz: 42dfd340ba7191b51b172615cfe7cef602906f88b30f5023e519bbea01e12e9ad2af7833607500cb9408a88b0f13144237dea0cbdfe36ed22bb3124f6e00ffe8
7
- data.tar.gz: a3b3fb6011989832dc5ae91cca827a63e17fb4a920d897a5ab0c8d76bf56d5c1ca822552f112f77fe3c3b7b62db1c183988cbf63ff48a83ea1135fa1c388b497
6
+ metadata.gz: 5a1090f0f7f56bec722d10554b502763c9b088d68b9b14392b1cc8a44f36807a942c4f0bb0d2f12c42f697de08f2567c0f813ed9f44016c5ca9dc373fc800ad4
7
+ data.tar.gz: 3e4413331e652b825035b38712187e9b8115d7595616d51a0b945c7ba91c4a1bf2d1e0bdc2aa77def5ed558244fb9004c8951e2f1bde59dd78ee7523e756363b
@@ -11,8 +11,9 @@ jobs:
11
11
  matrix:
12
12
  ruby:
13
13
  - 3.0.4
14
- - 2.7.6
15
14
  - 3.1.2
15
+ - 3.2.5
16
+ - 3.3.5
16
17
  services:
17
18
  dynamodb:
18
19
  image: amazon/dynamodb-local
data/Gemfile.lock CHANGED
@@ -1,18 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamoid_advanced_where (1.7.1)
4
+ dynamoid_advanced_where (1.8.0)
5
5
  dynamoid (>= 3.2, < 4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (7.0.4.3)
11
- activesupport (= 7.0.4.3)
12
- activesupport (7.0.4.3)
10
+ activemodel (7.1.4)
11
+ activesupport (= 7.1.4)
12
+ activesupport (7.1.4)
13
+ base64
14
+ bigdecimal
13
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ connection_pool (>= 2.2.5)
17
+ drb
14
18
  i18n (>= 1.6, < 2)
15
19
  minitest (>= 5.1)
20
+ mutex_m
16
21
  tzinfo (~> 2.0)
17
22
  addressable (2.8.1)
18
23
  public_suffix (>= 2.0.2, < 6.0)
@@ -21,29 +26,33 @@ GEM
21
26
  rake
22
27
  thor (>= 0.14.0)
23
28
  ast (2.4.2)
24
- aws-eventstream (1.2.0)
25
- aws-partitions (1.743.0)
26
- aws-sdk-core (3.171.0)
27
- aws-eventstream (~> 1, >= 1.0.2)
29
+ aws-eventstream (1.3.0)
30
+ aws-partitions (1.981.0)
31
+ aws-sdk-core (3.209.1)
32
+ aws-eventstream (~> 1, >= 1.3.0)
28
33
  aws-partitions (~> 1, >= 1.651.0)
29
- aws-sigv4 (~> 1.5)
34
+ aws-sigv4 (~> 1.9)
30
35
  jmespath (~> 1, >= 1.6.1)
31
- aws-sdk-dynamodb (1.83.0)
32
- aws-sdk-core (~> 3, >= 3.165.0)
33
- aws-sigv4 (~> 1.1)
34
- aws-sigv4 (1.5.2)
36
+ aws-sdk-dynamodb (1.125.0)
37
+ aws-sdk-core (~> 3, >= 3.207.0)
38
+ aws-sigv4 (~> 1.5)
39
+ aws-sigv4 (1.10.0)
35
40
  aws-eventstream (~> 1, >= 1.0.2)
41
+ base64 (0.2.0)
42
+ bigdecimal (3.1.8)
36
43
  bundler-audit (0.9.1)
37
44
  bundler (>= 1.2.0, < 3)
38
45
  thor (~> 1.0)
39
46
  childprocess (4.1.0)
40
47
  coderay (1.1.3)
41
48
  colorize (0.8.1)
42
- concurrent-ruby (1.2.2)
49
+ concurrent-ruby (1.3.4)
50
+ connection_pool (2.4.1)
43
51
  crack (0.4.5)
44
52
  rexml
45
- diff-lcs (1.5.0)
46
- dynamoid (3.8.0)
53
+ diff-lcs (1.5.1)
54
+ drb (2.2.1)
55
+ dynamoid (3.10.0)
47
56
  activemodel (>= 4)
48
57
  aws-sdk-dynamodb (~> 1.0)
49
58
  concurrent-ruby (>= 1.0)
@@ -51,13 +60,14 @@ GEM
51
60
  colorize (~> 0.7)
52
61
  ruby_parser (>= 3.19.1)
53
62
  hashdiff (1.0.1)
54
- i18n (1.12.0)
63
+ i18n (1.14.6)
55
64
  concurrent-ruby (~> 1.0)
56
65
  iniparse (1.5.0)
57
66
  jmespath (1.6.2)
58
67
  json (2.6.2)
59
68
  method_source (1.0.0)
60
- minitest (5.18.0)
69
+ minitest (5.25.1)
70
+ mutex_m (0.2.0)
61
71
  overcommit (0.59.1)
62
72
  childprocess (>= 0.6.3, < 5)
63
73
  iniparse (~> 1.4)
@@ -73,19 +83,19 @@ GEM
73
83
  rake (10.5.0)
74
84
  regexp_parser (2.6.0)
75
85
  rexml (3.2.5)
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)
86
+ rspec (3.13.0)
87
+ rspec-core (~> 3.13.0)
88
+ rspec-expectations (~> 3.13.0)
89
+ rspec-mocks (~> 3.13.0)
90
+ rspec-core (3.13.1)
91
+ rspec-support (~> 3.13.0)
92
+ rspec-expectations (3.13.3)
83
93
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.12.0)
85
- rspec-mocks (3.12.0)
94
+ rspec-support (~> 3.13.0)
95
+ rspec-mocks (3.13.1)
86
96
  diff-lcs (>= 1.2.0, < 2.0)
87
- rspec-support (~> 3.12.0)
88
- rspec-support (3.12.0)
97
+ rspec-support (~> 3.13.0)
98
+ rspec-support (3.13.1)
89
99
  rubocop (1.37.1)
90
100
  json (~> 2.3)
91
101
  parallel (~> 1.10)
data/README.md CHANGED
@@ -188,6 +188,9 @@ Provided methods
188
188
 
189
189
  `.start({ some_hash_key: some_value })` takes a hash argument that must match the key structure of the table (range key must be specified where valid). If passed an empty hash, results will start from the beginning of the table. Records before the specified start key will not be scanned or returned. This is useful when doing manual pagination.
190
190
 
191
+ ### Scaning backwards
192
+ `.scan_index_forward(false)` takes a boolean argument to indicate a query should be performed backwards. Errors if your query ends up scanning it will throw an error.
193
+
191
194
  ### Scan vs Query
192
195
  DAW will automatically preform a query when it determines it is possible,
193
196
  however if a query is determined to not be appropriate, a scan will be conduced
@@ -6,16 +6,17 @@ require_relative './batched_updater'
6
6
 
7
7
  module DynamoidAdvancedWhere
8
8
  class QueryBuilder
9
- attr_accessor :klass, :root_node, :start_hash, :record_limit, :projected_fields
9
+ attr_accessor :klass, :root_node, :start_hash, :record_limit, :projected_fields, :scanning_index_forward
10
10
 
11
11
  delegate :all, :each_page, :each, to: :query_materializer
12
12
 
13
- def initialize(klass:, projected_fields: [], record_limit: nil, start_hash: nil, root_node: nil, &blk)
13
+ def initialize(klass:, projected_fields: [], record_limit: nil, start_hash: nil, root_node: nil, scanning_index_forward: true, &blk)
14
14
  self.klass = klass
15
15
  self.root_node = root_node || Nodes::RootNode.new(klass: klass, &blk)
16
16
  self.start_hash = start_hash
17
17
  self.record_limit = record_limit
18
18
  self.projected_fields = projected_fields
19
+ self.scanning_index_forward = scanning_index_forward
19
20
 
20
21
  freeze
21
22
  end
@@ -58,6 +59,10 @@ module DynamoidAdvancedWhere
58
59
  dup_with_changes(record_limit: value)
59
60
  end
60
61
 
62
+ def scan_index_forward(value)
63
+ dup_with_changes(scanning_index_forward: value)
64
+ end
65
+
61
66
  def start(key_hash)
62
67
  return self if key_hash.nil? || key_hash.empty?
63
68
 
@@ -74,6 +79,7 @@ module DynamoidAdvancedWhere
74
79
  start_hash: start_hash,
75
80
  root_node: root_node,
76
81
  projected_fields: projected_fields,
82
+ scanning_index_forward: scanning_index_forward,
77
83
  }.merge(changes))
78
84
  end
79
85
  end
@@ -81,6 +81,7 @@ module DynamoidAdvancedWhere
81
81
  query = {
82
82
  table_name: table_name,
83
83
  index_name: selected_index_for_query,
84
+ scan_index_forward: query_builder.scanning_index_forward,
84
85
  }.merge(filter_builder.to_query_filter)
85
86
 
86
87
  enumerate_results(query) do |q|
@@ -89,6 +90,8 @@ module DynamoidAdvancedWhere
89
90
  end
90
91
 
91
92
  def each_page_via_scan
93
+ raise 'Unable to scan a table backwards' unless query_builder.scanning_index_forward
94
+
92
95
  query = {
93
96
  table_name: table_name,
94
97
  }.merge(filter_builder.to_scan_filter)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamoidAdvancedWhere
4
- VERSION = '1.7.1'
4
+ VERSION = '1.8.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.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Malinconico
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2024-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynamoid