- Feature - Add
ostructas a dependency to support Ruby 4.0.
- Feature - Drop Ruby runtime support for 2.5 and 2.6.
- Issue - Use configured clients for batch reads in
find_all.
- Issue - add
attribute_namesclass/instance method. (#145)
- Issue - Allow
global_secondary_indexto be defined inTableConfigwithout supplying capacity settings. (#140)
- Issue - Do not try to hydrate undeclared attributes from storage on
batch_read. (#139)
- Feature - Allow custom
update_expressionto be passed through to the underlying client calls. (#137)
-
Feature - Allow put, update, and delete item options to be passed through to the underlying client calls.
-
Feature - Add an
original_erroraccessor toErrors::ConditionalWriteFailedwhich contains theAws::DynamoDB::Errors::ConditionalCheckFailedExceptionerror. If:return_values_on_condition_check_failurewas provided to a put, update, or delete item call, this error will contain the item data that failed the condition check. -
Issue - Fix default value for String/Numeric Sets to be unset. (#133)
-
Feature - Set required Ruby version to >= 2.3 (#134)
-
Issue - Run Rubocop on all files. (#135)
- Feature - Improve User-Agent tracking and bump minimum DynamoDB version.
- Issue - Set
Aws::Record::VERSIONconstant from theVERSIONfile
- Feature - Implement the
BatchGetItemoperation (#122)
- Feature - Add support for inheritance. Aws Record models can now be extended using standard ruby inheritance (#80).
- Feature - Add support for atomic counter (#144)
- Feature - Implement the
BatchWriteItemoperation (#119)
- Issue - Fix FrozenError on BuildableSearch (#115)
- Feature - Add support for on-demand-billing for table migrations (#94)
- Feature -
Aws::Record::BuildableSearch- Support queries yielding heterogeneous results usingmulti_model_filter(#107)
- Issue - Allow symbols for database_attribute_name
- Issue - Correctly allow lambda/proc for default_value
- Feature - Aws::Record::BuildableSearch - Adds support for query and scan builders using substitution expressions. This allows for streamlined and expressive queries and scans using aws-record.
- Feature - Aws::Record::Transactions - Adds support for transactional find and transactional get requests. You can learn more about these new APIs in the documentation.
- Feature - Aws::Record::TableConfig - Adds support for the "PAY_PER_REQUEST" billing mode in table configurations.
- Issue - Aws::Record::Marshalers::EpochTimeMarshaler - Fixed a bug where epoch time objects didn't properly marshal from database entries.
-
Feature - Aws::Record::TableConfig - Adds
:ttl_attributeto the TableConfig DSL. When used withepoch_time_attrattributes or other attributes stored as epoch time, your TableConfig migrations will enable TTL on your DynamoDB table, and will use your specified attribute as the TTL attribute. -
Feature - Aws::Record::Marshalers::EpochTimeMarshaler - Adds the
epoch_time_attr, which behaves much liketime_attrexcept the Amazon DynamoDB storage type is numeric, and the serialized value is epoch seconds.
-
Feature - Aws::Record - Add the
persisted?,new_record?, anddestroyed?methods toAws::Record, which supports use cases where you'd like to see if a record has just been newly initialized, or has been deleted or was a preexisting record retrieved from DynamoDB. Note that these methods are present inActiveModel::Modelso you should require that module beforeAws::Record -
Feature - Aws::Record - Add the
assign_attributes,update, andupdate!methods toAws::Recordwhich supports the use case where the user might want to mass assign or update a records attributes by hash.update!also ensures that aValidationErroris thrown on an invalid update -
Upgrading - If you already include
ActiveModel::Modelon your models the newpersisted?,new_record?anddestroyed?methods will not function properly unless you includeActiveModel::ModelbeforeAws::Record. Additionally, new methods could lead to collisions if you happened to have attributes such as:updateor:assign_attributes. In such a case, you would want to version lock below2.1.0, or use the:database_attribute_nameproperty and change your attribute name in code.
- Feature - Aws::Record::Marshalers::TimeMarshaler - Adds the
time_attrmethod to AWS Record models, which usesTimeas the underlying type.
- Feature - Aws::Record::ItemCollection - Add the
#pageand#last_evaluated_keymethods toAws::Record::ItemCollection. This helps to support use cases where you'd like to control the result set size with the:limitparameter, or if you want to expose pagination capabilities to an outside caller, for example a list-type operation exposed in a web API.
- Upgrading - Aws::Record - Support version 3 of the AWS SDK for Ruby. This is
being released as major version 2 of
aws-record, though the APIs remain the same. Do note, however, that we've changed our SDK dependency to only depend onaws-sdk-dynamodb. This means that if you were depending on other service clients transitively viaaws-record, you will need to add dependencies on the appropriate service gems when upgrading.
-
Feature - Support lambdas for default attribute values.
date_attr :date, default_value -> { Date.today }
-
Issue - An attribute's default_value could be modified and carried over to new instances of the model. With this change, default values are deep copied, and are hydrated at item creation to ensure correct persistence of mutable objects.
-
Feature - Aws::Record::TableConfig - A declarative way to describe configuration for your Amazon DynamoDB tables, with smart migrations based on the current remote state. More details in the documentation.
-
Issue - Aws::Record::TableMigration - Legacy table migrations could have issues with global secondary indexes if a table was deleted and recreated multiple times.
- Feature - Aws::Record::ItemOperations - Adds the
find_with_optsclass method to model instances, which allows users to pass in both the key (as infind) and parameters which are to be passed through to the underlyingAws::DynamoDB::Client#get_itemcall.
- Issue - Aws::Record::ItemOperations - Fixes an issue where update operations
which consist of only
REMOVEexpressions failed due to an empty:expression_attribute_valuesmap. The fix makes the presence of that map conditional on the existance of valid values.
- Issue - Aws::Record::ItemCollection - Fixes a faulty
#empty?implementation, which could returnfalsefor a response which is, in fact, empty.
- Issue - Aws::Record - Fixes the
#table_exists?and#provisioned_throughputmethods, which could fail if called before#table_name.
- Feature - Aws::Record - Refactored tracking of model attributes, key attributes, and item data to use internal classes over module composition. Dirty tracking is also handled more consistently across attributes, and turning on/off of dirty tracking is only possible at the model level (not for individual attributes).
-
Feature - Aws::Record::Attribute - Added support for default values at the attribute level.
-
Feature - Aws::Record::Marshalers - Removed the marshalers in the
Aws::Attributesnamespace, replacing them with instantiated marshaler objects. This enables more functionality in marshalers such as the Date/DateTime marshalers. -
Feature - Aws::Record::DirtyTracking - Improves dirty tracking by adding support for tracking mutations of attribute value objects. This feature is on by default for the "collection" types:
:list_attr,:map_attr,:string_set_attr, and:numeric_set_attr.Before this feature, the
#savemethod's default behavior of running an update call for dirty attributes only could cause problems for users of collection attributes. As many of them are commonly manipulated using mutable state, the underlying "clean" version of the objects would be modified and the updated object would not be recognized as dirty, and therefore would not be updated at all unless explicitly marked as dirty or through a force put.class Model include Aws::Record string_attr :uuid, hash_key: true list_attr :collection end item = Model.new(uuid: SecureRandom.uuid, collection: [1,2,3]) item.clean! # As if loaded from the database, to demonstrate the new tracking. item.dirty? # => false item.collection << 4 # In place mutation of the "collection" array. item.dirty? # => true (Previous versions would not recognize this as dirty. item.save # Would call Aws::DynamoDB::Client#update_item for :collection only.
Note that this feature is implemented using deep copies of collection objects in memory, so there is a potential memory/performance hit in exchange for the added accuracy. As such, mutation tracking can be explicitly turned off at the attribute level or at the full model level, if desired.
# Note that the disabling of mutation tracking is redundant in this example, # for illustration purposes. class Model include Aws::Record disable_mutation_tracking # For turning off mutation at the model level. string_attr :uuid, hash_key: true list_attr :collection, mutation_tracking: false # Turn off at attr level. end
- Feature - Aws::Record - Adds the ability to set initial attribute values when
calling
#initialize. Additionally, can callupdateon a model to directly callAws::DynamoDB::Client#update_item.
-
Upgrading - Aws::Record - This release includes changes to validation and to the
#saveand#save!methods. With this release, the validation hooks inAws::Record::Attributehave been removed. Additionally,#savewill resume raising exceptions on client errors. However,#saveand#save!will attempt to call#valid?if defined on the model, and will return false or raise as appropriate if that method is defined and returns false.As a part of this change, we've removed the built in
#valid?and#errorsmethods. If you were a user of those, consider bringing your own validation library such asActiveModel::Validations. -
Issue - Aws::Record - Removes
#valid?and#errorsmethods, which caused a conflict with the ability to bring your own validation library such asActiveModel::Validations. Added tests as an example and to test compatibility.
- Feature - Aws::Record::Attributes - Improves default marshaling behavior for
set types. Now, if your object responds to
:to_set, such as an Array, it will automatically be marshaled to a set type when persisted.
-
Upgrading - Aws::Record - The conditional put/update logic added to
#saveand#save!is not backwards compatible in some cases. For example, the following code would work in previous versions, but not in this version:item = Model.new # Assume :id is the hash key, there is no range key. item.id = 1 item.content = "First write." item.save smash = Model.new smash.id = 1 smash.content = "Second write." smash.save # false, and populates the errors array. smash.save(force: true) # This will skip the conditional check and work. updatable = Model.find(id: 1) updatable.content = "Update write." updatable.save # This works and uses an update client call.
If you want to maintain previous behavior of unconditional puts, add the
force: trueoption to your#savecalls. However, this risks overwriting unmodeled attributes, or attributes excluded from your projection. But, the option is available for you to use. -
Upgrading - Aws::Record - The split of the
#savemethod into#saveand#save!breaks when your code is expecting#saveto raise exceptions.#savewill return false on a failed write and populate anerrorsarray. If you wish to raise exceptions on failed save attempts, use the#save!method. -
Feature - Aws::Record - Adds logic to determine if
#saveand#save!calls should useAws::DynamoDB::Client#put_itemorAws::DynamoDB::Client#update_item, depending on which item attributes are marked as dirty.#put_itemcalls are also made conditional on the key not existing, so accidental overwrites can be prevented. Old behavior of unconditional#put_itemcalls can be done using theforce: trueparameter. -
Feature - Aws::Record - Separates the
#savemethod into#saveand#save!.#save!will raise any errors that occur during persistence, while#savewill populate an errors array and cause#valid?calls on the item to returnfalse. -
Issue - Aws::Record - Changed how default table names are generated. In the past, the default table name could not handle class names that included modules. Now, module namespaces are appended to the default table name. This should not affect any existing model classes, as previously any affected models would have failed to create a table in DynamoDB.
- Feature - Aws::Record::DirtyTracking -
Aws::Recorditems will now keep track of "dirty" changes from database state. The DirtyTracking module provides a set of helper methods to handle dirty attributes.
- Feature - Aws::Record - Support for additional marshaled types, such as lists, maps, and string/numeric sets.
-
Feature - Aws::Record - Provides a low-level interface for the client
#queryand#scanmethods. Query and Scan results are surfaces as an enumerable collection ofAws::Recorditems. -
Feature - Aws::Record - Support for adding global secondary indexes and local secondary indexes to your model classes. Built-in support for creating these indexes at table creation time.
- Feature - Aws::Record - Initial development release of the
aws-recordgem. Includes basic table and item functionality for CRUD operations.