aws-record 2.11.0 → 2.13.0
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 +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
@@ -11,20 +11,27 @@ module Aws
|
|
11
11
|
# Saves this instance of an item to Amazon DynamoDB. If this item is "new"
|
12
12
|
# as defined by having new or altered key attributes, will attempt a
|
13
13
|
# conditional
|
14
|
-
# {http://docs.aws.amazon.com/
|
14
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
15
15
|
# Aws::DynamoDB::Client#put_item} call, which will not overwrite an existing
|
16
16
|
# item. If the item only has altered non-key attributes, will perform an
|
17
|
-
# {http://docs.aws.amazon.com/
|
17
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
18
18
|
# Aws::DynamoDB::Client#update_item} call. Uses this item instance's attributes
|
19
19
|
# in order to build the request on your behalf.
|
20
20
|
#
|
21
21
|
# You can use the +:force+ option to perform a simple put/overwrite
|
22
22
|
# without conditional validation or update logic.
|
23
23
|
#
|
24
|
-
# @param [Hash] opts
|
24
|
+
# @param [Hash] opts Options to pass through to the
|
25
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
26
|
+
# Aws::DynamoDB::Client#put_item} call or the
|
27
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
28
|
+
# Aws::DynamoDB::Client#update_item} call. +:put_item+ is used when
|
29
|
+
# +:force+ is true or when the item is new. +:update_item+ is used when
|
30
|
+
# the item is not new.
|
25
31
|
# @option opts [Boolean] :force if true, will save as a put operation and
|
26
32
|
# overwrite any existing item on the remote end. Otherwise, and by
|
27
33
|
# default, will either perform a conditional put or an update call.
|
34
|
+
#
|
28
35
|
# @raise [Aws::Record::Errors::KeyMissing] if a required key attribute
|
29
36
|
# does not have a value within this item instance.
|
30
37
|
# @raise [Aws::Record::Errors::ConditionalWriteFailed] if a conditional
|
@@ -34,30 +41,35 @@ module Aws
|
|
34
41
|
# cause is dependent on the validation library you are using.
|
35
42
|
def save!(opts = {})
|
36
43
|
ret = save(opts)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
raise Errors::ValidationError, 'Validation hook returned false!'
|
41
|
-
end
|
44
|
+
raise Errors::ValidationError, 'Validation hook returned false!' unless ret
|
45
|
+
|
46
|
+
ret
|
42
47
|
end
|
43
48
|
|
44
49
|
# Saves this instance of an item to Amazon DynamoDB. If this item is "new"
|
45
50
|
# as defined by having new or altered key attributes, will attempt a
|
46
51
|
# conditional
|
47
|
-
# {http://docs.aws.amazon.com/
|
52
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
48
53
|
# Aws::DynamoDB::Client#put_item} call, which will not overwrite an
|
49
54
|
# existing item. If the item only has altered non-key attributes, will perform an
|
50
|
-
# {http://docs.aws.amazon.com/
|
55
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
51
56
|
# Aws::DynamoDB::Client#update_item} call. Uses this item instance's attributes
|
52
57
|
# in order to build the request on your behalf.
|
53
58
|
#
|
54
59
|
# You can use the +:force+ option to perform a simple put/overwrite
|
55
60
|
# without conditional validation or update logic.
|
56
61
|
#
|
57
|
-
# @param [Hash] opts
|
62
|
+
# @param [Hash] opts Options to pass through to the
|
63
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
64
|
+
# Aws::DynamoDB::Client#put_item} call or the
|
65
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
66
|
+
# Aws::DynamoDB::Client#update_item} call. +:put_item+ is used when
|
67
|
+
# +:force+ is true or when the item is new. +:update_item+ is used when
|
68
|
+
# the item is not new.
|
58
69
|
# @option opts [Boolean] :force if true, will save as a put operation and
|
59
70
|
# overwrite any existing item on the remote end. Otherwise, and by
|
60
71
|
# default, will either perform a conditional put or an update call.
|
72
|
+
#
|
61
73
|
# @return false if the record is invalid as defined by an attempt to call
|
62
74
|
# +valid?+ on this item, if that method exists. Otherwise, returns client
|
63
75
|
# call return value.
|
@@ -98,6 +110,7 @@ module Aws
|
|
98
110
|
field = field.to_sym
|
99
111
|
setter = "#{field}="
|
100
112
|
raise ArgumentError, "Invalid field: #{field} for model" unless respond_to?(setter)
|
113
|
+
|
101
114
|
public_send(setter, new_value)
|
102
115
|
end
|
103
116
|
end
|
@@ -132,12 +145,19 @@ module Aws
|
|
132
145
|
# model.dirty? # => false
|
133
146
|
#
|
134
147
|
#
|
135
|
-
# @param [Hash]
|
148
|
+
# @param [Hash] new_params Contains the new parameters for the model.
|
136
149
|
#
|
137
|
-
# @param [Hash] opts
|
150
|
+
# @param [Hash] opts Options to pass through to the
|
151
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
152
|
+
# Aws::DynamoDB::Client#put_item} call or the
|
153
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
154
|
+
# Aws::DynamoDB::Client#update_item} call. +:put_item+ is used when
|
155
|
+
# +:force+ is true or when the item is new. +:update_item+ is used when
|
156
|
+
# the item is not new.
|
138
157
|
# @option opts [Boolean] :force if true, will save as a put operation and
|
139
158
|
# overwrite any existing item on the remote end. Otherwise, and by
|
140
159
|
# default, will either perform a conditional put or an update call.
|
160
|
+
#
|
141
161
|
# @return false if the record is invalid as defined by an attempt to call
|
142
162
|
# +valid?+ on this item, if that method exists. Otherwise, returns client
|
143
163
|
# call return value.
|
@@ -155,12 +175,18 @@ module Aws
|
|
155
175
|
# but this will be interpreted as persisting a new item to your DynamoDB
|
156
176
|
# table
|
157
177
|
#
|
158
|
-
# @param [Hash]
|
159
|
-
#
|
160
|
-
#
|
178
|
+
# @param [Hash] new_params Contains the new parameters for the model.
|
179
|
+
# @param [Hash] opts Options to pass through to the
|
180
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#put_item-instance_method
|
181
|
+
# Aws::DynamoDB::Client#put_item} call or the
|
182
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
183
|
+
# Aws::DynamoDB::Client#update_item} call. +:put_item+ is used when
|
184
|
+
# +:force+ is true or when the item is new. +:update_item+ is used when
|
185
|
+
# the item is not new.
|
161
186
|
# @option opts [Boolean] :force if true, will save as a put operation and
|
162
187
|
# overwrite any existing item on the remote end. Otherwise, and by
|
163
188
|
# default, will either perform a conditional put or an update call.
|
189
|
+
#
|
164
190
|
# @return The update mode if the update is successful
|
165
191
|
#
|
166
192
|
# @raise [Aws::Record::Errors::ValidationError] if any new values
|
@@ -172,18 +198,23 @@ module Aws
|
|
172
198
|
|
173
199
|
# Deletes the item instance that matches the key values of this item
|
174
200
|
# instance in Amazon DynamoDB. Uses the
|
175
|
-
# {http://docs.aws.amazon.com/
|
201
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
176
202
|
# Aws::DynamoDB::Client#delete_item} API.
|
177
|
-
|
178
|
-
|
203
|
+
#
|
204
|
+
# @param [Hash] opts Options to pass through to the
|
205
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
206
|
+
# Aws::DynamoDB::Client#delete_item} call.
|
207
|
+
def delete!(opts = {})
|
208
|
+
delete_opts = {
|
179
209
|
table_name: self.class.table_name,
|
180
210
|
key: key_values
|
181
|
-
|
211
|
+
}
|
212
|
+
dynamodb_client.delete_item(opts.merge(delete_opts))
|
182
213
|
instance_variable_get('@data').destroyed = true
|
183
214
|
end
|
184
215
|
|
185
216
|
# Validates and generates the key values necessary for API operations such as the
|
186
|
-
# {http://docs.aws.amazon.com/
|
217
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#delete_item-instance_method
|
187
218
|
# Aws::DynamoDB::Client#delete_item} operation.
|
188
219
|
def key_values
|
189
220
|
validate_key_values
|
@@ -207,59 +238,53 @@ module Aws
|
|
207
238
|
|
208
239
|
def _invalid_record?(_opts)
|
209
240
|
if respond_to?(:valid?)
|
210
|
-
|
211
|
-
true
|
212
|
-
else
|
213
|
-
false
|
214
|
-
end
|
241
|
+
!valid?
|
215
242
|
else
|
216
243
|
false
|
217
244
|
end
|
218
245
|
end
|
219
246
|
|
220
247
|
def _perform_save(opts)
|
221
|
-
force = opts
|
248
|
+
force = opts.delete(:force)
|
222
249
|
expect_new = expect_new_item?
|
223
250
|
if force
|
224
|
-
|
251
|
+
put_opts = {
|
225
252
|
table_name: self.class.table_name,
|
226
253
|
item: _build_item_for_save
|
227
|
-
|
254
|
+
}
|
255
|
+
dynamodb_client.put_item(opts.merge(put_opts))
|
228
256
|
elsif expect_new
|
229
257
|
put_opts = {
|
230
258
|
table_name: self.class.table_name,
|
231
259
|
item: _build_item_for_save
|
232
260
|
}.merge(prevent_overwrite_expression)
|
233
261
|
begin
|
234
|
-
dynamodb_client.put_item(put_opts)
|
235
|
-
rescue Aws::DynamoDB::Errors::ConditionalCheckFailedException
|
236
|
-
raise Errors::ConditionalWriteFailed
|
237
|
-
|
238
|
-
|
239
|
-
|
262
|
+
dynamodb_client.put_item(opts.merge(put_opts))
|
263
|
+
rescue Aws::DynamoDB::Errors::ConditionalCheckFailedException => e
|
264
|
+
raise Errors::ConditionalWriteFailed.new(
|
265
|
+
'Conditional #put_item call failed! Check that conditional write ' \
|
266
|
+
'conditions are met, or include the :force option to clobber ' \
|
267
|
+
'the remote item.',
|
268
|
+
e
|
269
|
+
)
|
240
270
|
end
|
241
271
|
else
|
272
|
+
update_opts = {
|
273
|
+
table_name: self.class.table_name,
|
274
|
+
key: key_values
|
275
|
+
}
|
242
276
|
update_pairs = _dirty_changes_for_update
|
243
|
-
|
277
|
+
update_expression_opts = self.class.send(
|
244
278
|
:_build_update_expression,
|
245
279
|
update_pairs
|
246
280
|
)
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
}
|
255
|
-
request_opts[:expression_attribute_values] = exp_attr_values unless exp_attr_values.empty?
|
256
|
-
dynamodb_client.update_item(request_opts)
|
257
|
-
else
|
258
|
-
dynamodb_client.update_item(
|
259
|
-
table_name: self.class.table_name,
|
260
|
-
key: key_values
|
261
|
-
)
|
262
|
-
end
|
281
|
+
opts = self.class.send(
|
282
|
+
:_merge_update_expression_opts,
|
283
|
+
update_expression_opts,
|
284
|
+
opts
|
285
|
+
)
|
286
|
+
resp = dynamodb_client.update_item(opts.merge(update_opts))
|
287
|
+
assign_attributes(resp[:attributes]) if resp[:attributes]
|
263
288
|
end
|
264
289
|
data = instance_variable_get('@data')
|
265
290
|
data.destroyed = false
|
@@ -311,11 +336,10 @@ module Aws
|
|
311
336
|
end
|
312
337
|
|
313
338
|
def _dirty_changes_for_update
|
314
|
-
|
339
|
+
dirty.each_with_object({}) do |attr_name, acc|
|
315
340
|
acc[attr_name] = @data.raw_value(attr_name)
|
316
341
|
acc
|
317
342
|
end
|
318
|
-
ret
|
319
343
|
end
|
320
344
|
|
321
345
|
module ItemOperationsClassMethods
|
@@ -350,9 +374,8 @@ module Aws
|
|
350
374
|
key = opts.delete(:key)
|
351
375
|
check_key = {}
|
352
376
|
@keys.keys.each_value do |attr_sym|
|
353
|
-
unless key[attr_sym]
|
354
|
-
|
355
|
-
end
|
377
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}" unless key[attr_sym]
|
378
|
+
|
356
379
|
attr_name = attributes.storage_name_for(attr_sym)
|
357
380
|
check_key[attr_name] = attributes.attribute_for(attr_sym)
|
358
381
|
.serialize(key[attr_sym])
|
@@ -374,9 +397,8 @@ module Aws
|
|
374
397
|
key = opts.delete(:key)
|
375
398
|
request_key = {}
|
376
399
|
@keys.keys.each_value do |attr_sym|
|
377
|
-
unless key[attr_sym]
|
378
|
-
|
379
|
-
end
|
400
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}" unless key[attr_sym]
|
401
|
+
|
380
402
|
attr_name = attributes.storage_name_for(attr_sym)
|
381
403
|
request_key[attr_name] = attributes.attribute_for(attr_sym)
|
382
404
|
.serialize(key[attr_sym])
|
@@ -468,30 +490,33 @@ module Aws
|
|
468
490
|
# supports the options you are including, and avoid adding options not
|
469
491
|
# recognized by the underlying client to avoid runtime exceptions.
|
470
492
|
#
|
471
|
-
# @param [Hash] opts Options to pass through to the
|
472
|
-
#
|
473
|
-
#
|
493
|
+
# @param [Hash] opts Options to pass through to the
|
494
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#get_item-instance_method
|
495
|
+
# Aws::DynamoDB::Client#get_item} request. The +:key+ option is a
|
496
|
+
# special case where attributes are serialized and translated for you
|
497
|
+
# similar to the #find method.
|
474
498
|
# @option opts [Hash] :key attribute-value pairs for the key you wish to
|
475
499
|
# search for.
|
500
|
+
#
|
476
501
|
# @return [Aws::Record] builds and returns an instance of your model.
|
502
|
+
#
|
477
503
|
# @raise [Aws::Record::Errors::KeyMissing] if your option parameters do
|
478
504
|
# not include all table keys.
|
479
505
|
def find_with_opts(opts)
|
480
506
|
key = opts.delete(:key)
|
481
507
|
request_key = {}
|
482
508
|
@keys.keys.each_value do |attr_sym|
|
483
|
-
unless key[attr_sym]
|
484
|
-
|
485
|
-
end
|
509
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{key}" unless key[attr_sym]
|
510
|
+
|
486
511
|
attr_name = attributes.storage_name_for(attr_sym)
|
487
512
|
request_key[attr_name] = attributes.attribute_for(attr_sym)
|
488
513
|
.serialize(key[attr_sym])
|
489
514
|
end
|
490
|
-
|
515
|
+
get_opts = {
|
491
516
|
table_name: table_name,
|
492
517
|
key: request_key
|
493
518
|
}.merge(opts)
|
494
|
-
resp = dynamodb_client.get_item(
|
519
|
+
resp = dynamodb_client.get_item(get_opts)
|
495
520
|
if resp.item.nil?
|
496
521
|
nil
|
497
522
|
else
|
@@ -547,38 +572,37 @@ module Aws
|
|
547
572
|
# MyModel.update(id: 1, name: "First", body: "Hello!")
|
548
573
|
#
|
549
574
|
# Performs an
|
550
|
-
# {http://docs.aws.amazon.com/
|
575
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
551
576
|
# Aws::DynamoDB::Client#update_item} call immediately on the table,
|
552
577
|
# using the attribute key/value pairs provided.
|
553
578
|
#
|
554
|
-
# @param [Hash]
|
555
|
-
# wish to perform. You must include all key attributes for a valid
|
579
|
+
# @param [Hash] new_params attribute-value pairs for the update operation
|
580
|
+
# you wish to perform. You must include all key attributes for a valid
|
556
581
|
# call, then you may optionally include any other attributes that you
|
557
582
|
# wish to update.
|
583
|
+
# @param [Hash] opts Options to pass through to the
|
584
|
+
# {http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#update_item-instance_method
|
585
|
+
# Aws::DynamoDB::Client#update_item} call.
|
586
|
+
#
|
558
587
|
# @raise [Aws::Record::Errors::KeyMissing] if your option parameters do
|
559
588
|
# not include all table keys.
|
560
|
-
def update(opts)
|
589
|
+
def update(new_params, opts = {})
|
561
590
|
key = {}
|
562
591
|
@keys.keys.each_value do |attr_sym|
|
563
|
-
unless (value =
|
564
|
-
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{
|
565
|
-
|
592
|
+
unless (value = new_params.delete(attr_sym))
|
593
|
+
raise Errors::KeyMissing, "Missing required key #{attr_sym} in #{new_params}"
|
566
594
|
end
|
595
|
+
|
567
596
|
attr_name = attributes.storage_name_for(attr_sym)
|
568
597
|
key[attr_name] = attributes.attribute_for(attr_sym).serialize(value)
|
569
598
|
end
|
570
|
-
|
599
|
+
update_opts = {
|
571
600
|
table_name: table_name,
|
572
601
|
key: key
|
573
602
|
}
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
request_opts[:update_expression] = uex
|
578
|
-
request_opts[:expression_attribute_names] = exp_attr_names
|
579
|
-
request_opts[:expression_attribute_values] = exp_attr_values unless exp_attr_values.empty?
|
580
|
-
end
|
581
|
-
dynamodb_client.update_item(request_opts)
|
603
|
+
update_expression_opts = _build_update_expression(new_params)
|
604
|
+
opts = _merge_update_expression_opts(update_expression_opts, opts)
|
605
|
+
dynamodb_client.update_item(opts.merge(update_opts))
|
582
606
|
end
|
583
607
|
|
584
608
|
private
|
@@ -591,8 +615,8 @@ module Aws
|
|
591
615
|
name_sub_token = 'UE_A'
|
592
616
|
value_sub_token = 'ue_a'
|
593
617
|
attr_value_pairs.each do |attr_sym, value|
|
594
|
-
name_sub =
|
595
|
-
value_sub =
|
618
|
+
name_sub = "##{name_sub_token}"
|
619
|
+
value_sub = ":#{value_sub_token}"
|
596
620
|
name_sub_token = name_sub_token.succ
|
597
621
|
value_sub_token = value_sub_token.succ
|
598
622
|
|
@@ -607,16 +631,24 @@ module Aws
|
|
607
631
|
end
|
608
632
|
end
|
609
633
|
update_expressions = []
|
610
|
-
unless set_expressions.empty?
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
634
|
+
update_expressions << ("SET #{set_expressions.join(', ')}") unless set_expressions.empty?
|
635
|
+
update_expressions << ("REMOVE #{remove_expressions.join(', ')}") unless remove_expressions.empty?
|
636
|
+
{
|
637
|
+
update_expression: update_expressions.join(' '),
|
638
|
+
expression_attribute_names: exp_attr_names,
|
639
|
+
expression_attribute_values: exp_attr_values
|
640
|
+
}.reject { |_, value| value.nil? || value.empty? }
|
641
|
+
end
|
642
|
+
|
643
|
+
def _merge_update_expression_opts(update_expression_opts, pass_through_opts)
|
644
|
+
update_expression_opts.merge(pass_through_opts) do |key, expression_value, pass_through_value|
|
645
|
+
case key
|
646
|
+
when :update_expression
|
647
|
+
msg = 'Using pass-through update expression with attribute updates is not supported.'
|
648
|
+
raise Errors::UpdateExpressionCollision, msg
|
649
|
+
else
|
650
|
+
expression_value.merge(pass_through_value)
|
651
|
+
end
|
620
652
|
end
|
621
653
|
end
|
622
654
|
|
@@ -4,13 +4,13 @@ module Aws
|
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
6
|
class BooleanMarshaler
|
7
|
-
def initialize(opts = {})
|
7
|
+
def initialize(opts = {})
|
8
|
+
# pass
|
9
|
+
end
|
8
10
|
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
nil
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
nil
|
15
15
|
when false, 'false', '0', 0
|
16
16
|
false
|
@@ -35,15 +35,11 @@ module Aws
|
|
35
35
|
|
36
36
|
def _format(raw_value)
|
37
37
|
case raw_value
|
38
|
-
when nil
|
39
|
-
nil
|
40
|
-
when ''
|
38
|
+
when nil, ''
|
41
39
|
nil
|
42
40
|
when ::Time
|
43
41
|
raw_value
|
44
|
-
when Integer # timestamp
|
45
|
-
::Time.at(raw_value)
|
46
|
-
when BigDecimal
|
42
|
+
when Integer, BigDecimal # timestamp
|
47
43
|
::Time.at(raw_value)
|
48
44
|
else # Date, DateTime, or String
|
49
45
|
::Time.parse(raw_value.to_s)
|
@@ -4,13 +4,13 @@ module Aws
|
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
6
|
class FloatMarshaler
|
7
|
-
def initialize(opts = {})
|
7
|
+
def initialize(opts = {})
|
8
|
+
# pass
|
9
|
+
end
|
8
10
|
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
nil
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
nil
|
15
15
|
when Float
|
16
16
|
raw_value
|
@@ -4,13 +4,13 @@ module Aws
|
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
6
|
class IntegerMarshaler
|
7
|
-
def initialize(opts = {})
|
7
|
+
def initialize(opts = {})
|
8
|
+
# pass
|
9
|
+
end
|
8
10
|
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
nil
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
nil
|
15
15
|
when Integer
|
16
16
|
raw_value
|
@@ -4,13 +4,13 @@ module Aws
|
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
6
|
class ListMarshaler
|
7
|
-
def initialize(opts = {})
|
7
|
+
def initialize(opts = {})
|
8
|
+
# pass
|
9
|
+
end
|
8
10
|
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
nil
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
nil
|
15
15
|
when Array
|
16
16
|
raw_value
|
@@ -18,8 +18,8 @@ module Aws
|
|
18
18
|
if raw_value.respond_to?(:to_a)
|
19
19
|
raw_value.to_a
|
20
20
|
else
|
21
|
-
msg = "Don't know how to make #{raw_value} of type"\
|
22
|
-
|
21
|
+
msg = "Don't know how to make #{raw_value} of type " \
|
22
|
+
"#{raw_value.class} into an array!"
|
23
23
|
raise ArgumentError, msg
|
24
24
|
end
|
25
25
|
end
|
@@ -4,13 +4,13 @@ module Aws
|
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
6
|
class MapMarshaler
|
7
|
-
def initialize(opts = {})
|
7
|
+
def initialize(opts = {})
|
8
|
+
# pass
|
9
|
+
end
|
8
10
|
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
nil
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
nil
|
15
15
|
when Hash
|
16
16
|
raw_value
|
@@ -18,8 +18,8 @@ module Aws
|
|
18
18
|
if raw_value.respond_to?(:to_h)
|
19
19
|
raw_value.to_h
|
20
20
|
else
|
21
|
-
msg = "Don't know how to make #{raw_value} of type"\
|
22
|
-
|
21
|
+
msg = "Don't know how to make #{raw_value} of type " \
|
22
|
+
"#{raw_value.class} into a hash!"
|
23
23
|
raise ArgumentError, msg
|
24
24
|
end
|
25
25
|
end
|
@@ -3,14 +3,14 @@
|
|
3
3
|
module Aws
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
|
-
|
7
|
-
|
6
|
+
def initialize(opts = {})
|
7
|
+
# pass
|
8
|
+
end
|
8
9
|
|
10
|
+
class NumericSetMarshaler
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
Set.new
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
Set.new
|
15
15
|
when Set
|
16
16
|
_as_numeric(raw_value)
|
@@ -18,8 +18,8 @@ module Aws
|
|
18
18
|
if raw_value.respond_to?(:to_set)
|
19
19
|
_as_numeric(raw_value.to_set)
|
20
20
|
else
|
21
|
-
msg = "Don't know how to make #{raw_value} of type"\
|
22
|
-
|
21
|
+
msg = "Don't know how to make #{raw_value} of type " \
|
22
|
+
"#{raw_value.class} into a Numeric Set!"
|
23
23
|
raise ArgumentError, msg
|
24
24
|
end
|
25
25
|
end
|
@@ -4,13 +4,13 @@ module Aws
|
|
4
4
|
module Record
|
5
5
|
module Marshalers
|
6
6
|
class StringSetMarshaler
|
7
|
-
def initialize(opts = {})
|
7
|
+
def initialize(opts = {})
|
8
|
+
# pass
|
9
|
+
end
|
8
10
|
|
9
11
|
def type_cast(raw_value)
|
10
12
|
case raw_value
|
11
|
-
when nil
|
12
|
-
Set.new
|
13
|
-
when ''
|
13
|
+
when nil, ''
|
14
14
|
Set.new
|
15
15
|
when Set
|
16
16
|
_as_strings(raw_value)
|
@@ -18,8 +18,8 @@ module Aws
|
|
18
18
|
if raw_value.respond_to?(:to_set)
|
19
19
|
_as_strings(raw_value.to_set)
|
20
20
|
else
|
21
|
-
msg = "Don't know how to make #{raw_value} of type"\
|
22
|
-
|
21
|
+
msg = "Don't know how to make #{raw_value} of type " \
|
22
|
+
"#{raw_value.class} into a String Set!"
|
23
23
|
raise ArgumentError, msg
|
24
24
|
end
|
25
25
|
end
|