aws-record 2.11.0 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +84 -19
- data/VERSION +1 -1
- data/lib/aws-record/record/attribute.rb +4 -2
- data/lib/aws-record/record/batch_read.rb +8 -13
- data/lib/aws-record/record/batch_write.rb +2 -1
- data/lib/aws-record/record/buildable_search.rb +15 -20
- data/lib/aws-record/record/client_configuration.rb +7 -7
- data/lib/aws-record/record/dirty_tracking.rb +3 -11
- data/lib/aws-record/record/errors.rb +18 -1
- data/lib/aws-record/record/item_collection.rb +5 -5
- data/lib/aws-record/record/item_data.rb +10 -11
- data/lib/aws-record/record/item_operations.rb +128 -96
- data/lib/aws-record/record/marshalers/boolean_marshaler.rb +4 -4
- data/lib/aws-record/record/marshalers/date_marshaler.rb +1 -3
- data/lib/aws-record/record/marshalers/date_time_marshaler.rb +1 -3
- data/lib/aws-record/record/marshalers/epoch_time_marshaler.rb +2 -6
- data/lib/aws-record/record/marshalers/float_marshaler.rb +4 -4
- data/lib/aws-record/record/marshalers/integer_marshaler.rb +4 -4
- data/lib/aws-record/record/marshalers/list_marshaler.rb +6 -6
- data/lib/aws-record/record/marshalers/map_marshaler.rb +6 -6
- data/lib/aws-record/record/marshalers/numeric_set_marshaler.rb +7 -7
- data/lib/aws-record/record/marshalers/string_marshaler.rb +3 -1
- data/lib/aws-record/record/marshalers/string_set_marshaler.rb +6 -6
- data/lib/aws-record/record/marshalers/time_marshaler.rb +1 -3
- data/lib/aws-record/record/model_attributes.rb +14 -16
- data/lib/aws-record/record/query.rb +4 -4
- data/lib/aws-record/record/secondary_indexes.rb +22 -25
- data/lib/aws-record/record/table_config.rb +45 -56
- data/lib/aws-record/record/table_migration.rb +32 -36
- data/lib/aws-record/record/transactions.rb +15 -23
- data/lib/aws-record/record/version.rb +1 -1
- data/lib/aws-record/record.rb +8 -8
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4101d86e9fc3c9644b701a42e3ff48c09a24f60169d5d1c0d6cd9aced0ff8e64
|
4
|
+
data.tar.gz: d672cbe2ab1b4e8b27749729fe0810684501a564893f6cc2d704e63581dfe53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d63848749ec893de308eb3e97e3131b6479d0f4781f1277ac14f4dbbeed0a6fdb6237546ba881f41448c1c5933d00a960c25091af8e85cbb768bf5560d4c3d89
|
7
|
+
data.tar.gz: f4feb5e0f1c6199945cb18cbfd3ca9a61344c795643aba58ec73a958dc0b315365bc82632e31eced2a2ada684b635e6fead8ef4995ae7b5c4babc46802d137fb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
2.13.0 (2023-10-17)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* Feature - Allow custom `update_expression` to be passed through to the
|
5
|
+
underlying client calls. (#137)
|
6
|
+
|
7
|
+
2.12.0 (2023-09-28)
|
8
|
+
------------------
|
9
|
+
|
10
|
+
* Feature - Allow put, update, and delete item options to be passed through to
|
11
|
+
the underlying client calls.
|
12
|
+
|
13
|
+
* Feature - Add an `original_error` accessor to `Errors::ConditionalWriteFailed`
|
14
|
+
which contains the `Aws::DynamoDB::Errors::ConditionalCheckFailedException`
|
15
|
+
error. If `:return_values_on_condition_check_failure` was provided to a put,
|
16
|
+
update, or delete item call, this error will contain the item data that failed
|
17
|
+
the condition check.
|
18
|
+
|
19
|
+
* Issue - Fix default value for String/Numeric Sets to be unset. (#133)
|
20
|
+
|
21
|
+
* Feature - Set required Ruby version to >= 2.3 (#134)
|
22
|
+
|
23
|
+
* Issue - Run Rubocop on all files. (#135)
|
24
|
+
|
1
25
|
2.11.0 (2023-06-02)
|
2
26
|
------------------
|
3
27
|
|
@@ -16,7 +40,8 @@
|
|
16
40
|
2.9.0 (2022-11-16)
|
17
41
|
------------------
|
18
42
|
|
19
|
-
* Feature - Add support for inheritance. Aws Record models can now be extended
|
43
|
+
* Feature - Add support for inheritance. Aws Record models can now be extended
|
44
|
+
using standard ruby inheritance (#80).
|
20
45
|
|
21
46
|
2.8.0 (2022-10-12)
|
22
47
|
------------------
|
@@ -41,7 +66,8 @@
|
|
41
66
|
2.5.0 (2020-10-13)
|
42
67
|
------------------
|
43
68
|
|
44
|
-
* Feature - `Aws::Record::BuildableSearch` - Support queries yielding
|
69
|
+
* Feature - `Aws::Record::BuildableSearch` - Support queries yielding
|
70
|
+
heterogeneous results using `multi_model_filter` (#107)
|
45
71
|
|
46
72
|
2.4.1 (2020-05-29)
|
47
73
|
------------------
|
@@ -52,53 +78,89 @@
|
|
52
78
|
2.4.0 (2019-07-16)
|
53
79
|
------------------
|
54
80
|
|
55
|
-
* Feature - Aws::Record::BuildableSearch - Adds support for query and scan
|
81
|
+
* Feature - Aws::Record::BuildableSearch - Adds support for query and scan
|
82
|
+
builders using substitution expressions. This allows for streamlined and
|
83
|
+
expressive queries and scans using aws-record.
|
56
84
|
|
57
85
|
2.3.0 (2019-02-08)
|
58
86
|
------------------
|
59
87
|
|
60
|
-
* Feature - Aws::Record::Transactions - Adds support for transactional find and
|
88
|
+
* Feature - Aws::Record::Transactions - Adds support for transactional find and
|
89
|
+
transactional get requests. You can learn more about these new APIs in
|
90
|
+
the [documentation](https://docs.aws.amazon.com/awssdkrubyrecord/api/Aws/Record/Transactions.html).
|
61
91
|
|
62
92
|
2.2.0 (2018-12-05)
|
63
93
|
------------------
|
64
94
|
|
65
|
-
* Feature - Aws::Record::TableConfig - Adds support for the "PAY_PER_REQUEST"
|
95
|
+
* Feature - Aws::Record::TableConfig - Adds support for the "PAY_PER_REQUEST"
|
96
|
+
billing mode in table configurations.
|
66
97
|
|
67
98
|
2.1.2 (2018-11-15)
|
68
99
|
------------------
|
69
100
|
|
70
|
-
* Issue - Aws::Record::Marshalers::EpochTimeMarshaler - Fixed a bug where epoch
|
101
|
+
* Issue - Aws::Record::Marshalers::EpochTimeMarshaler - Fixed a bug where epoch
|
102
|
+
time objects didn't properly marshal from database entries.
|
71
103
|
|
72
104
|
2.1.1 (2018-07-10)
|
73
105
|
------------------
|
74
106
|
|
75
|
-
* Feature - Aws::Record::TableConfig - Adds `:ttl_attribute` to the TableConfig
|
107
|
+
* Feature - Aws::Record::TableConfig - Adds `:ttl_attribute` to the TableConfig
|
108
|
+
DSL. When used with `epoch_time_attr` attributes or other attributes stored as
|
109
|
+
epoch time, your TableConfig migrations will enable TTL on your DynamoDB
|
110
|
+
table, and will use your specified attribute as the TTL attribute.
|
76
111
|
|
77
|
-
* Feature - Aws::Record::Marshalers::EpochTimeMarshaler - Adds
|
112
|
+
* Feature - Aws::Record::Marshalers::EpochTimeMarshaler - Adds
|
113
|
+
the `epoch_time_attr`, which behaves much like `time_attr` except the Amazon
|
114
|
+
DynamoDB storage type is numeric, and the serialized value is epoch seconds.
|
78
115
|
|
79
116
|
2.1.0 (2018-06-25)
|
80
117
|
------------------
|
81
118
|
|
82
|
-
* Feature - Aws::Record - Add the `persisted?`, `new_record?`, and `destroyed?`
|
119
|
+
* Feature - Aws::Record - Add the `persisted?`, `new_record?`, and `destroyed?`
|
120
|
+
methods to `Aws::Record`, which supports use cases where you'd like to see if
|
121
|
+
a record has just been newly initialized, or has been deleted or was a
|
122
|
+
preexisting record retrieved from DynamoDB. Note that these methods are
|
123
|
+
present in `ActiveModel::Model` so you should require that module
|
124
|
+
before `Aws::Record`
|
83
125
|
|
84
|
-
* Feature - Aws::Record - Add the `assign_attributes`, `update`, and `update!`
|
126
|
+
* Feature - Aws::Record - Add the `assign_attributes`, `update`, and `update!`
|
127
|
+
methods to `Aws::Record` which supports the use case where the user might want
|
128
|
+
to mass assign or update a records attributes by hash. `update!` also ensures
|
129
|
+
that a `ValidationError` is thrown on an invalid update
|
85
130
|
|
86
|
-
* Upgrading - If you already include `ActiveModel::Model` on your models the
|
131
|
+
* Upgrading - If you already include `ActiveModel::Model` on your models the
|
132
|
+
new `persisted?`, `new_record?` and `destroyed?` methods will not function
|
133
|
+
properly unless you include `ActiveModel::Model` before `Aws::Record`.
|
134
|
+
Additionally, new methods could lead to collisions if you happened to have
|
135
|
+
attributes such as `:update` or `:assign_attributes`. In such a case, you
|
136
|
+
would want to version lock below `2.1.0`, or use
|
137
|
+
the `:database_attribute_name` property and change your attribute name in
|
138
|
+
code.
|
87
139
|
|
88
140
|
2.0.2 (2018-06-08)
|
89
141
|
------------------
|
90
142
|
|
91
|
-
* Feature - Aws::Record::Marshalers::TimeMarshaler - Adds the `time_attr` method
|
143
|
+
* Feature - Aws::Record::Marshalers::TimeMarshaler - Adds the `time_attr` method
|
144
|
+
to AWS Record models, which uses `Time` as the underlying type.
|
92
145
|
|
93
146
|
2.0.1 (2017-10-27)
|
94
147
|
------------------
|
95
148
|
|
96
|
-
* Feature - Aws::Record::ItemCollection - Add the `#page`
|
149
|
+
* Feature - Aws::Record::ItemCollection - Add the `#page`
|
150
|
+
and `#last_evaluated_key` methods to `Aws::Record::ItemCollection`. This helps
|
151
|
+
to support use cases where you'd like to control the result set size with
|
152
|
+
the `:limit` parameter, or if you want to expose pagination capabilities to an
|
153
|
+
outside caller, for example a list-type operation exposed in a web API.
|
97
154
|
|
98
155
|
2.0.0 (2017-08-29)
|
99
156
|
------------------
|
100
157
|
|
101
|
-
* Upgrading - Aws::Record - Support version 3 of the AWS SDK for Ruby. This is
|
158
|
+
* Upgrading - Aws::Record - Support version 3 of the AWS SDK for Ruby. This is
|
159
|
+
being released as major version 2 of `aws-record`, though the APIs remain the
|
160
|
+
same. Do note, however, that we've changed our SDK dependency to only depend
|
161
|
+
on `aws-sdk-dynamodb`. This means that if you were depending on other service
|
162
|
+
clients transitively via `aws-record`, you will need to add dependencies on
|
163
|
+
the appropriate service gems when upgrading.
|
102
164
|
|
103
165
|
1.1.1 (2017-06-16)
|
104
166
|
------------------
|
@@ -160,18 +222,21 @@
|
|
160
222
|
1.0.0.pre.10 (2016-08-03)
|
161
223
|
------------------
|
162
224
|
|
163
|
-
* Feature - Aws::Record - Refactored tracking of model attributes, key
|
164
|
-
|
225
|
+
* Feature - Aws::Record - Refactored tracking of model attributes, key
|
226
|
+
attributes,
|
227
|
+
and item data to use internal classes over module composition. Dirty tracking
|
228
|
+
is
|
165
229
|
also handled more consistently across attributes, and turning on/off of dirty
|
166
230
|
tracking is only possible at the model level (not for individual attributes).
|
167
231
|
|
168
232
|
1.0.0.pre.9 (2016-07-22)
|
169
233
|
------------------
|
170
234
|
|
171
|
-
* Feature - Aws::Record::Attribute - Added support for default values at the
|
172
|
-
level.
|
235
|
+
* Feature - Aws::Record::Attribute - Added support for default values at the
|
236
|
+
attribute level.
|
173
237
|
|
174
|
-
* Feature - Aws::Record::Marshalers - Removed the marshalers in
|
238
|
+
* Feature - Aws::Record::Marshalers - Removed the marshalers in
|
239
|
+
the `Aws::Attributes`
|
175
240
|
namespace, replacing them with instantiated marshaler objects. This enables
|
176
241
|
more functionality in marshalers such as the Date/DateTime marshalers.
|
177
242
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.13.0
|
@@ -40,8 +40,10 @@ module Aws
|
|
40
40
|
@dynamodb_type = options[:dynamodb_type]
|
41
41
|
@marshaler = options[:marshaler] || DefaultMarshaler
|
42
42
|
@persist_nil = options[:persist_nil]
|
43
|
-
|
44
|
-
|
43
|
+
@default_value_or_lambda = if options.key?(:default_value)
|
44
|
+
dv = options[:default_value]
|
45
|
+
_is_lambda?(dv) ? dv : type_cast(dv)
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
# Attempts to type cast a raw value into the attribute's type. This call
|
@@ -8,7 +8,8 @@ module Aws
|
|
8
8
|
# @api private
|
9
9
|
BATCH_GET_ITEM_LIMIT = 100
|
10
10
|
|
11
|
-
# @param [
|
11
|
+
# @param [Hash] opts
|
12
|
+
# @option opts [Aws::DynamoDB::Client] client the DynamoDB SDK client.
|
12
13
|
def initialize(opts = {})
|
13
14
|
@client = opts[:client]
|
14
15
|
end
|
@@ -44,9 +45,7 @@ module Aws
|
|
44
45
|
new_items = build_items(result.responses)
|
45
46
|
items.concat(new_items)
|
46
47
|
|
47
|
-
unless result.unprocessed_keys.nil?
|
48
|
-
update_unprocessed_keys(result.unprocessed_keys)
|
49
|
-
end
|
48
|
+
update_unprocessed_keys(result.unprocessed_keys) unless result.unprocessed_keys.nil?
|
50
49
|
|
51
50
|
new_items
|
52
51
|
end
|
@@ -61,16 +60,14 @@ module Aws
|
|
61
60
|
# @yieldparam [Aws::Record] item a modeled item
|
62
61
|
# @return [Enumerable<BatchRead>] an enumeration over the results of
|
63
62
|
# +batch_get_item+ request.
|
64
|
-
def each
|
63
|
+
def each(&block)
|
65
64
|
return enum_for(:each) unless block_given?
|
66
65
|
|
67
|
-
@items.each
|
68
|
-
yield(item)
|
69
|
-
end
|
66
|
+
@items.each(&block)
|
70
67
|
|
71
68
|
until complete?
|
72
69
|
new_items = execute!
|
73
|
-
new_items.each
|
70
|
+
new_items.each(&block)
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
@@ -105,9 +102,7 @@ module Aws
|
|
105
102
|
item_key = {}
|
106
103
|
attributes = klass.attributes
|
107
104
|
klass.keys.each_value do |attr_sym|
|
108
|
-
unless key[attr_sym]
|
109
|
-
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}"
|
110
|
-
end
|
105
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}" unless key[attr_sym]
|
111
106
|
|
112
107
|
attr_name = attributes.storage_name_for(attr_sym)
|
113
108
|
item_key[attr_name] = attributes.attribute_for(attr_sym)
|
@@ -146,7 +141,7 @@ module Aws
|
|
146
141
|
item_class = find_item_class(table, item)
|
147
142
|
if item_class.nil? && @client.config.logger
|
148
143
|
@client.config.logger.warn(
|
149
|
-
'Unexpected response from service.'\
|
144
|
+
'Unexpected response from service.' \
|
150
145
|
"Received: #{item}. Skipping above item and continuing"
|
151
146
|
)
|
152
147
|
else
|
@@ -3,7 +3,8 @@
|
|
3
3
|
module Aws
|
4
4
|
module Record
|
5
5
|
class BatchWrite
|
6
|
-
# @param [
|
6
|
+
# @param [Hash] opts
|
7
|
+
# @option opts [Aws::DynamoDB::Client] client the DynamoDB SDK client.
|
7
8
|
def initialize(opts = {})
|
8
9
|
@client = opts[:client]
|
9
10
|
end
|
@@ -10,11 +10,10 @@ module Aws
|
|
10
10
|
def initialize(opts)
|
11
11
|
operation = opts[:operation]
|
12
12
|
model = opts[:model]
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
13
|
+
raise ArgumentError, "Unsupported operation: #{operation}" unless SUPPORTED_OPERATIONS.include?(operation)
|
14
|
+
|
15
|
+
@operation = operation
|
16
|
+
|
18
17
|
@model = model
|
19
18
|
@params = {}
|
20
19
|
@next_name = 'BUILDERA'
|
@@ -41,12 +40,11 @@ module Aws
|
|
41
40
|
# builder method to provide the :total_segments of your parallel scan and
|
42
41
|
# the :segment number of this scan.
|
43
42
|
def parallel_scan(opts)
|
44
|
-
unless @operation == :scan
|
45
|
-
raise ArgumentError, 'parallel_scan is only supported for scans'
|
46
|
-
end
|
43
|
+
raise ArgumentError, 'parallel_scan is only supported for scans' unless @operation == :scan
|
47
44
|
unless opts[:total_segments] && opts[:segment]
|
48
45
|
raise ArgumentError, 'Must specify :total_segments and :segment in a parallel scan.'
|
49
46
|
end
|
47
|
+
|
50
48
|
@params[:total_segments] = opts[:total_segments]
|
51
49
|
@params[:segment] = opts[:segment]
|
52
50
|
self
|
@@ -56,9 +54,8 @@ module Aws
|
|
56
54
|
# ascending or descending order on your range key. By default, a query is
|
57
55
|
# run in ascending order.
|
58
56
|
def scan_ascending(b)
|
59
|
-
unless @operation == :query
|
60
|
-
|
61
|
-
end
|
57
|
+
raise ArgumentError, 'scan_ascending is only supported for queries.' unless @operation == :query
|
58
|
+
|
62
59
|
@params[:scan_index_forward] = b
|
63
60
|
self
|
64
61
|
end
|
@@ -90,9 +87,8 @@ module Aws
|
|
90
87
|
# ).complete!
|
91
88
|
# q.to_a # You can use this like any other query result in aws-record
|
92
89
|
def key_expr(statement_str, *subs)
|
93
|
-
unless @operation == :query
|
94
|
-
|
95
|
-
end
|
90
|
+
raise ArgumentError, 'key_expr is only supported for queries.' unless @operation == :query
|
91
|
+
|
96
92
|
names = @params[:expression_attribute_names]
|
97
93
|
if names.nil?
|
98
94
|
@params[:expression_attribute_names] = {}
|
@@ -252,28 +248,27 @@ module Aws
|
|
252
248
|
|
253
249
|
def _apply_values(statement, subs, values)
|
254
250
|
count = 0
|
255
|
-
result = statement.gsub(/[?]/) do
|
251
|
+
result = statement.gsub(/[?]/) do
|
256
252
|
sub_value = _next_value
|
257
253
|
raise 'Substitution collision!' if values[sub_value]
|
254
|
+
|
258
255
|
values[sub_value] = subs[count]
|
259
256
|
count += 1
|
260
257
|
sub_value
|
261
258
|
end
|
262
259
|
result.tap do
|
263
|
-
unless count == subs.size
|
264
|
-
raise "Expected #{count} values in the substitution set, but found #{subs.size}"
|
265
|
-
end
|
260
|
+
raise "Expected #{count} values in the substitution set, but found #{subs.size}" unless count == subs.size
|
266
261
|
end
|
267
262
|
end
|
268
263
|
|
269
264
|
def _next_name
|
270
|
-
ret =
|
265
|
+
ret = "##{@next_name}"
|
271
266
|
@next_name = @next_name.next
|
272
267
|
ret
|
273
268
|
end
|
274
269
|
|
275
270
|
def _next_value
|
276
|
-
ret =
|
271
|
+
ret = ":#{@next_value}"
|
277
272
|
@next_value = @next_value.next
|
278
273
|
ret
|
279
274
|
end
|
@@ -10,7 +10,7 @@ module Aws
|
|
10
10
|
# attempt to perform an operation against the remote end, if you have not
|
11
11
|
# already configured a client. As such, please read and understand the
|
12
12
|
# documentation in the AWS SDK for Ruby around
|
13
|
-
# {http://docs.aws.amazon.com/
|
13
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/index.html#Configuration configuration}
|
14
14
|
# to ensure you understand how default configuration behavior works. When
|
15
15
|
# in doubt, call this method to ensure your client is configured the way
|
16
16
|
# you want it to be configured.
|
@@ -26,12 +26,12 @@ module Aws
|
|
26
26
|
# own pre-configured client.
|
27
27
|
def configure_client(opts = {})
|
28
28
|
# rubocop:disable Style/RedundantSelf
|
29
|
-
if self.class != Module && Aws::Record.extends_record?(self) && opts.empty? &&
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
@dynamodb_client = if self.class != Module && Aws::Record.extends_record?(self) && opts.empty? &&
|
30
|
+
self.superclass.instance_variable_get('@dynamodb_client')
|
31
|
+
self.superclass.instance_variable_get('@dynamodb_client')
|
32
|
+
else
|
33
|
+
_build_client(opts)
|
34
|
+
end
|
35
35
|
# rubocop:enable Style/RedundantSelf
|
36
36
|
end
|
37
37
|
|
@@ -203,11 +203,9 @@ module Aws
|
|
203
203
|
|
204
204
|
record = self.class.find(primary_key)
|
205
205
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
raise Errors::NotFound, 'No record found'
|
210
|
-
end
|
206
|
+
raise Errors::NotFound, 'No record found' unless record.present?
|
207
|
+
|
208
|
+
@data = record.instance_variable_get('@data')
|
211
209
|
|
212
210
|
clean!
|
213
211
|
|
@@ -258,8 +256,6 @@ module Aws
|
|
258
256
|
end
|
259
257
|
|
260
258
|
# @private
|
261
|
-
#
|
262
|
-
# @override save(*)
|
263
259
|
def save(*)
|
264
260
|
super.tap { clean! }
|
265
261
|
end
|
@@ -268,15 +264,11 @@ module Aws
|
|
268
264
|
private
|
269
265
|
|
270
266
|
# @private
|
271
|
-
#
|
272
|
-
# @override build_item_from_resp(*)
|
273
267
|
def build_item_from_resp(*)
|
274
268
|
super.tap(&:clean!)
|
275
269
|
end
|
276
270
|
|
277
271
|
# @private
|
278
|
-
#
|
279
|
-
# @override define_attr_methods(*)
|
280
272
|
def _define_attr_methods(name)
|
281
273
|
super.tap do
|
282
274
|
define_method("#{name}_dirty?") do
|
@@ -16,7 +16,17 @@ module Aws
|
|
16
16
|
class NotFound < RecordError; end
|
17
17
|
|
18
18
|
# Raised when a conditional write fails.
|
19
|
-
|
19
|
+
# Provides access to the original ConditionalCheckFailedException error
|
20
|
+
# which may have item data if the return values option was used.
|
21
|
+
class ConditionalWriteFailed < RecordError
|
22
|
+
def initialize(message, original_error)
|
23
|
+
@original_error = original_error
|
24
|
+
super(message)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Aws::DynamoDB::Errors::ConditionalCheckFailedException]
|
28
|
+
attr_reader :original_error
|
29
|
+
end
|
20
30
|
|
21
31
|
# Raised when a validation hook call to +:valid?+ fails.
|
22
32
|
class ValidationError < RecordError; end
|
@@ -50,6 +60,13 @@ module Aws
|
|
50
60
|
# the key existance check yourself in your condition expression if you
|
51
61
|
# wish to do so.
|
52
62
|
class TransactionalSaveConditionCollision < RuntimeError; end
|
63
|
+
|
64
|
+
# Raised when you attempt to combine your own update expression with
|
65
|
+
# the update expression auto-generated from updates to an item's
|
66
|
+
# attributes. The path forward until this case is supported is to
|
67
|
+
# perform attribute updates yourself in your update expression if you
|
68
|
+
# wish to do so.
|
69
|
+
class UpdateExpressionCollision < RuntimeError; end
|
53
70
|
end
|
54
71
|
end
|
55
72
|
end
|
@@ -25,14 +25,13 @@ module Aws
|
|
25
25
|
# @return [Enumerable<Aws::Record>] an enumeration over the results of
|
26
26
|
# your query or scan request. These results are automatically converted
|
27
27
|
# into items on your behalf.
|
28
|
-
def each
|
28
|
+
def each(&block)
|
29
29
|
return enum_for(:each) unless block_given?
|
30
|
+
|
30
31
|
items.each_page do |page|
|
31
32
|
@last_evaluated_key = page.last_evaluated_key
|
32
33
|
items_array = _build_items_from_response(page.items, @model)
|
33
|
-
items_array.each
|
34
|
-
yield item
|
35
|
-
end
|
34
|
+
items_array.each(&block)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
@@ -84,6 +83,7 @@ module Aws
|
|
84
83
|
items.each do |item|
|
85
84
|
model_class = @model_filter ? @model_filter.call(item) : model
|
86
85
|
next unless model_class
|
86
|
+
|
87
87
|
record = model_class.new
|
88
88
|
data = record.instance_variable_get('@data')
|
89
89
|
model_class.attributes.attributes.each do |name, attr|
|
@@ -97,7 +97,7 @@ module Aws
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def items
|
100
|
-
@
|
100
|
+
@items ||= @client.send(@search_method, @search_params)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -47,11 +47,11 @@ module Aws
|
|
47
47
|
@model_attributes.attributes.each_key do |name|
|
48
48
|
populate_default_values
|
49
49
|
value = get_attribute(name)
|
50
|
-
if @track_mutations
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
@clean_copies[name] = if @track_mutations
|
51
|
+
_deep_copy(value)
|
52
|
+
else
|
53
|
+
value
|
54
|
+
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -80,7 +80,7 @@ module Aws
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def dirty?
|
83
|
-
dirty.empty?
|
83
|
+
!dirty.empty?
|
84
84
|
end
|
85
85
|
|
86
86
|
def rollback_attribute!(name)
|
@@ -109,11 +109,10 @@ module Aws
|
|
109
109
|
|
110
110
|
def populate_default_values
|
111
111
|
@model_attributes.attributes.each do |name, attribute|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
112
|
+
next if (default_value = attribute.default_value).nil?
|
113
|
+
next unless @data[name].nil?
|
114
|
+
|
115
|
+
@data[name] = default_value
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|