dynamoid 3.8.0 → 3.12.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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -2
  3. data/README.md +375 -64
  4. data/SECURITY.md +17 -0
  5. data/dynamoid.gemspec +65 -0
  6. data/lib/dynamoid/adapter.rb +21 -14
  7. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb +2 -2
  8. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/execute_statement.rb +62 -0
  9. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/filter_expression_convertor.rb +113 -0
  10. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/item_updater.rb +29 -2
  11. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/middleware/limit.rb +3 -0
  12. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/projection_expression_convertor.rb +40 -0
  13. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/query.rb +46 -61
  14. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/scan.rb +34 -28
  15. data/lib/dynamoid/adapter_plugin/aws_sdk_v3/transact.rb +31 -0
  16. data/lib/dynamoid/adapter_plugin/aws_sdk_v3.rb +132 -74
  17. data/lib/dynamoid/associations/belongs_to.rb +6 -6
  18. data/lib/dynamoid/associations.rb +1 -1
  19. data/lib/dynamoid/components.rb +3 -3
  20. data/lib/dynamoid/config/options.rb +12 -12
  21. data/lib/dynamoid/config.rb +4 -0
  22. data/lib/dynamoid/criteria/chain.rb +165 -149
  23. data/lib/dynamoid/criteria/key_fields_detector.rb +6 -7
  24. data/lib/dynamoid/criteria/nonexistent_fields_detector.rb +2 -2
  25. data/lib/dynamoid/criteria/where_conditions.rb +36 -0
  26. data/lib/dynamoid/dirty.rb +145 -59
  27. data/lib/dynamoid/document.rb +39 -3
  28. data/lib/dynamoid/dumping.rb +41 -19
  29. data/lib/dynamoid/errors.rb +32 -3
  30. data/lib/dynamoid/fields/declare.rb +6 -6
  31. data/lib/dynamoid/fields.rb +21 -29
  32. data/lib/dynamoid/finders.rb +68 -51
  33. data/lib/dynamoid/indexes.rb +7 -10
  34. data/lib/dynamoid/loadable.rb +3 -2
  35. data/lib/dynamoid/log/formatter.rb +19 -4
  36. data/lib/dynamoid/persistence/import.rb +4 -1
  37. data/lib/dynamoid/persistence/inc.rb +82 -0
  38. data/lib/dynamoid/persistence/item_updater_with_casting_and_dumping.rb +36 -0
  39. data/lib/dynamoid/persistence/item_updater_with_dumping.rb +33 -0
  40. data/lib/dynamoid/persistence/save.rb +75 -17
  41. data/lib/dynamoid/persistence/update_fields.rb +24 -9
  42. data/lib/dynamoid/persistence/update_validations.rb +3 -3
  43. data/lib/dynamoid/persistence/upsert.rb +22 -8
  44. data/lib/dynamoid/persistence.rb +308 -72
  45. data/lib/dynamoid/transaction_read/find.rb +137 -0
  46. data/lib/dynamoid/transaction_read.rb +146 -0
  47. data/lib/dynamoid/transaction_write/base.rb +47 -0
  48. data/lib/dynamoid/transaction_write/create.rb +49 -0
  49. data/lib/dynamoid/transaction_write/delete_with_instance.rb +65 -0
  50. data/lib/dynamoid/transaction_write/delete_with_primary_key.rb +64 -0
  51. data/lib/dynamoid/transaction_write/destroy.rb +84 -0
  52. data/lib/dynamoid/transaction_write/item_updater.rb +55 -0
  53. data/lib/dynamoid/transaction_write/save.rb +169 -0
  54. data/lib/dynamoid/transaction_write/update_attributes.rb +46 -0
  55. data/lib/dynamoid/transaction_write/update_fields.rb +239 -0
  56. data/lib/dynamoid/transaction_write/upsert.rb +106 -0
  57. data/lib/dynamoid/transaction_write.rb +673 -0
  58. data/lib/dynamoid/type_casting.rb +18 -15
  59. data/lib/dynamoid/undumping.rb +14 -3
  60. data/lib/dynamoid/validations.rb +8 -5
  61. data/lib/dynamoid/version.rb +1 -1
  62. data/lib/dynamoid.rb +8 -0
  63. metadata +43 -49
  64. data/lib/dynamoid/criteria/ignored_conditions_detector.rb +0 -41
  65. data/lib/dynamoid/criteria/overwritten_conditions_detector.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e1643f808e93716814d86080198b41cdf26991d9e75614f7d877561590b23d9
4
- data.tar.gz: 453bb6e2c52d73cc94db42ba550fc621524ecba4cc4703445a00977d013b5c9a
3
+ metadata.gz: f3e330233bdd01c0bb962fb7253b48629fe9f0aeb1ecdcb6cfe7d3272ddddbe0
4
+ data.tar.gz: 7f6ee27e8d6dedb5fe21bce21a6c00397f42d85dfa40b8d30dae4e13a8294d15
5
5
  SHA512:
6
- metadata.gz: 3cc09e208f6d1be1bf953efda001cb006fa8a752830e192a418ba449807163761427dd443fac32ee3cb34cf690e613c3ff1e34a3cf0515d50f609319b71c69e7
7
- data.tar.gz: 8ded4ae6a694788719dfc152adb6890f5cd18ff38acf99e422b824ed28c2d010e54caf05016af230d3cb49e5900618ced303148ebbc6ea5dce391dc838c278b2
6
+ metadata.gz: f84a868794dd6b812ccd6936eaa16c91a8d0f87b2ae959b89a8b01802537490168449bfa83f62d92f8643a6c47043cefeb9168da3301ca4f005400bc1086406f
7
+ data.tar.gz: 528587c73879f49d25e660974fa5832464eed5773da06535a76bfe3c9c96311a1877eb801e68362c94eadc479cf65a8df053a0f47574c78fbf5919859cb88e66
data/CHANGELOG.md CHANGED
@@ -5,15 +5,102 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
+
9
+ ### Fixed
10
+ ### Added
11
+ ### Changed
12
+ ### Removed
13
+
14
+ ## 3.12.0
15
+
8
16
  ### Fixed
17
+ * [#849](https://github.com/Dynamoid/dynamoid/pull/849) Fixed saving a field of custom type when it implements both `.dynamoid_dump()` and `#dynamoid_dump` method and use the former one.
18
+ A proper behaviour is to use adapter's .dynamoid_dump method instead of a value's #dynamoid_dump method.
19
+ * [#851](https://github.com/Dynamoid/dynamoid/pull/851) Fixed Dirty API and don't require custom types to implement `#==` method. Add field option `:comparable`.
20
+ * [#913](https://github.com/Dynamoid/dynamoid/pull/913) Fixed saving partition keys of Dynamoid-specific types (e.g. `date` or `datetime`) and always convert them into a proper DynamoDB type
21
+ * [#917](https://github.com/Dynamoid/dynamoid/pull/917) Fixed transactional write operations when primary key is of non-native DynamoDB type
22
+ * [#927](https://github.com/Dynamoid/dynamoid/pull/927) Multiple fixes in transactional and non-transactional write methods and finders:
23
+ * Changed non-transactional method `#find` and raise `MissingHashKey` when a given partition key is `nil`
24
+ * Fixed non-transactional method `#save!` and raise `RecordNotSaved` when a callback throws `:abort` and terminates the process
25
+ * Check whether partition and sort key are specified in the non-transactional persistence methods and raise a proper exception (`MissingHashKey` or `MissingRangeKey`)
26
+ * Fixed methods `#inc`, `#increment!` and `#decrement!`, `#update` and `#update!` to not create a new item when an item with specified primary key is already deleted
27
+ * Fixed method `#update_attribute` to not raise `StaleObjectError` when an item with specified primary key is already deleted
28
+ * Fixed method `#where` with condition on a `:serialized` field to not raise an exception
29
+ ### Added
30
+ * [#910](https://github.com/Dynamoid/dynamoid/pull/910) Added `key_type` option to the `table` method to change type of a partition key field (@ogidow)
31
+ * [#916](https://github.com/Dynamoid/dynamoid/pull/916) Added new `error_on_scan` config option to raises an error and prevent table scans (DynamoDB's `Scan` operation) (@aaronalberg)
32
+ * [#926](https://github.com/Dynamoid/dynamoid/pull/926) Implemented read transactions (using DynamoDB's `TransactGetItems` operation)
33
+ ### Changed
34
+ * [#846](https://github.com/Dynamoid/dynamoid/pull/846) Changed transactional `update_fields()` method to accept a block and support low-level operations `set`, `add`, `delete`, `remove` (similar to the non-transactional `#update()` method) (@ckhsponge)
35
+ ### Removed
9
36
 
37
+ ## 3.11.0 / 2025-01-12
38
+ ### Fixed
39
+ * [#829](https://github.com/Dynamoid/dynamoid/pull/829) Fixed saving of in-place field changes
40
+ * [#812](https://github.com/Dynamoid/dynamoid/pull/812) Restored sanitizing of attribute names in `#where` conditions
41
+ * [#721](https://github.com/Dynamoid/dynamoid/pull/721) Fixed code examples in README.md (@ndjndj)
10
42
  ### Added
43
+ * [#688](https://github.com/Dynamoid/dynamoid/pull/688) Implemented write transactions (using DynamoDB's `TransactWriteItems` operation) (@ckhsponge)
44
+ * [#794](https://github.com/Dynamoid/dynamoid/pull/794) Added new config option `store_empty_string_as_nil`
45
+ * [#828](https://github.com/Dynamoid/dynamoid/pull/828) Added Ruby 3.4, Rails 8.0 and Rails 7.2 in CI
46
+ ### Changed
47
+ * [#832](https://github.com/Dynamoid/dynamoid/pull/832) Support String condition expressions with `#where`
48
+ * [#822](https://github.com/Dynamoid/dynamoid/pull/822) Support binary type natively. Also added new config option `store_binary_as_native` (@dalibor)
11
49
 
50
+ ## 3.10.0 / 2024-02-10
51
+ ### Fixed
52
+ * [#681](https://github.com/Dynamoid/dynamoid/pull/681) Fixed saving persisted model and deleting attributes with `nil` value if `config.store_attribute_with_nil_value` is `false`
53
+ * [#716](https://github.com/Dynamoid/dynamoid/pull/716), [#691](https://github.com/Dynamoid/dynamoid/pull/691), [#687](https://github.com/Dynamoid/dynamoid/pull/687), [#660](https://github.com/Dynamoid/dynamoid/pull/660) Numerous fixes in README.md and RDoc documentation (@ndjndj, @kiharito, @dunkOnIT)
54
+ ### Added
55
+ * [#656](https://github.com/Dynamoid/dynamoid/pull/656) Added a `create_table_on_save` configuration flag to create table on save (@imaximix)
56
+ * [#697](https://github.com/Dynamoid/dynamoid/pull/697) Ensure Ruby 3.3 and Rails 7.1 versions are supported and added them on CI
12
57
  ### Changed
58
+ * [#655](https://github.com/Dynamoid/dynamoid/pull/655) Support multiple `where` in the same chain with multiple conditions for the same field
13
59
 
14
- ### Removed
60
+ ## 3.9.0 / 2023-04-13
61
+ ### Fixed
62
+ * [#610](https://github.com/Dynamoid/dynamoid/pull/610) Specs in JRuby; Support for JRuby 9.4.0.0 (@pboling)
63
+ * [#624](https://github.com/Dynamoid/dynamoid/pull/624) Fixed `#increment!`/`#decrement!` methods and made them compatible with Rails counterparts
64
+ * [#626](https://github.com/Dynamoid/dynamoid/pull/626) Fixed saving empty Set and String and replacing with `nil` in `#update`, `#update!`, `.update_fields`, and `.upsert` methods
65
+ * [#628](https://github.com/Dynamoid/dynamoid/pull/628) Fixed `.import` method to mark persisted model attributes as not changed/not dirty
66
+ * [#632](https://github.com/Dynamoid/dynamoid/pull/632) Fixed `#save` called with `touch: false` option to set `updated_at` attribute even for a new record (to comply with Rails)
67
+ * [#634](https://github.com/Dynamoid/dynamoid/pull/634) Fixed model callbacks:
68
+ * changed order of `save` and `create`/`update` callbacks - `save` callbacks are outer for the `create`/`update` ones
69
+ * removed `before_initialize` and `around_initialize` callbacks - there should be only `after_initialize` one
70
+ * [#634](https://github.com/Dynamoid/dynamoid/pull/634) Fixed `#touch` method compatibility with a Rails counterpart:
71
+ * don't save other modified attributes - only timestamps
72
+ * don't perform validation and don't call `save`/`create`/`update` callbacks
73
+ * accept a list of attribute names, but not one name
74
+ * accept a `:time` option
75
+ ### Added
76
+ * [#611](https://github.com/Dynamoid/dynamoid/pull/611) Add `rubocop-md` (@pboling)
77
+ * [#612](https://github.com/Dynamoid/dynamoid/pull/612) Add `rubocop-rspec` (@pboling)
78
+ * [#613](https://github.com/Dynamoid/dynamoid/pull/613) Add `rubocop-performance` and `rubocop-rake` (@pboling)
79
+ * Added `funding_uri` set to open collective: https://opencollective.com/dynamoid
80
+ * Added `required_ruby_version` as `>= 2.3.0` (which was already the minimum supported version of Ruby)
81
+ * [#616](https://github.com/Dynamoid/dynamoid/pull/616) Upgrade `simplecov` (& remove `coveralls`) (@pboling)
82
+ * Setup GitHub actions for Code Coverage
83
+ * Setup GitHub actions for RuboCop linting
84
+ * Automate coverage feedback on Pull Requests via GitHub Actions and CodeCov
85
+ * [#618](https://github.com/Dynamoid/dynamoid/pull/618) Upgrade README Badges (@pboling)
86
+ * [#624](https://github.com/Dynamoid/dynamoid/pull/624) Added `:touch` option for `.inc` method to be more compatible with the Rails counterpart method `.update_counters`
87
+ * [#627](https://github.com/Dynamoid/dynamoid/pull/627) Made the following methods in the Dirty API public (to comply with Rails):
88
+ * `clear_changes_information`
89
+ * `changes_applied`
90
+ * `clear_attribute_changes`
91
+ * [#630](https://github.com/Dynamoid/dynamoid/pull/630) Added `Dynamoid::Adapter#execute` method to run PartiQL queries
92
+ * [#634](https://github.com/Dynamoid/dynamoid/pull/634) Added `after_touch` callback and run it in the following methods:
93
+ * `#touch`
94
+ * `#increment!`
95
+ * `#decrement!`
96
+ * [#642](https://github.com/Dynamoid/dynamoid/pull/642) Run specs on CI against Ruby 3.2
97
+ * [#645](https://github.com/Dynamoid/dynamoid/pull/645) Added `after_find` callback
98
+ ### Changed
99
+ * [#610](https://github.com/Dynamoid/dynamoid/pull/610) Switch to [`rubocop-lts`](https://rubocop-lts.gitlab.io/) (@pboling)
100
+ * [#633](https://github.com/Dynamoid/dynamoid/pull/633) Change `#inspect` method to return only attributes
101
+ * [#623](https://github.com/Dynamoid/dynamoid/pull/623) Optimized performance of persisting to send only changed attributes in a request to DynamoDB
15
102
 
16
- ## 3.8.0
103
+ ## 3.8.0 / 2022-11-09
17
104
  ### Fixed
18
105
  * [#525](https://github.com/Dynamoid/dynamoid/pull/525) Don't mark an attribute as changed if new assigned value equals the old one (@a5-stable)
19
106
  * Minor changes in the documentation: