- Issue - add
attribute_names
class/instance method. (#145)
- Issue - Allow
global_secondary_index
to be defined inTableConfig
without supplying capacity settings. (#140)
- Issue - Do not try to hydrate undeclared attributes from storage on
batch_read
. (#139)
- Feature - Allow custom
update_expression
to 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_error
accessor toErrors::ConditionalWriteFailed
which contains theAws::DynamoDB::Errors::ConditionalCheckFailedException
error. If:return_values_on_condition_check_failure
was 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::VERSION
constant from theVERSION
file
- Feature - Implement the
BatchGetItem
operation (#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
BatchWriteItem
operation (#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_attribute
to the TableConfig DSL. When used withepoch_time_attr
attributes 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_attr
except 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::Model
so you should require that module beforeAws::Record
-
Feature - Aws::Record - Add the
assign_attributes
,update
, andupdate!
methods toAws::Record
which supports the use case where the user might want to mass assign or update a records attributes by hash.update!
also ensures that aValidationError
is thrown on an invalid update -
Upgrading - If you already include
ActiveModel::Model
on your models the newpersisted?
,new_record?
anddestroyed?
methods will not function properly unless you includeActiveModel::Model
beforeAws::Record
. Additionally, new methods could lead to collisions if you happened to have attributes such as:update
or:assign_attributes
. In such a case, you would want to version lock below2.1.0
, or use the:database_attribute_name
property and change your attribute name in code.
- Feature - Aws::Record::Marshalers::TimeMarshaler - Adds the
time_attr
method to AWS Record models, which usesTime
as the underlying type.
- Feature - Aws::Record::ItemCollection - Add the
#page
and#last_evaluated_key
methods toAws::Record::ItemCollection
. This helps to support use cases where you'd like to control the result set size with the:limit
parameter, 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_opts
class 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_item
call.
- Issue - Aws::Record::ItemOperations - Fixes an issue where update operations
which consist of only
REMOVE
expressions failed due to an empty:expression_attribute_values
map. 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 returnfalse
for a response which is, in fact, empty.
- Issue - Aws::Record - Fixes the
#table_exists?
and#provisioned_throughput
methods, 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::Attributes
namespace, 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
#save
method'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 callupdate
on a model to directly callAws::DynamoDB::Client#update_item
.
-
Upgrading - Aws::Record - This release includes changes to validation and to the
#save
and#save!
methods. With this release, the validation hooks inAws::Record::Attribute
have been removed. Additionally,#save
will resume raising exceptions on client errors. However,#save
and#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#errors
methods. If you were a user of those, consider bringing your own validation library such asActiveModel::Validations
. -
Issue - Aws::Record - Removes
#valid?
and#errors
methods, 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
#save
and#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: true
option to your#save
calls. 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
#save
method into#save
and#save!
breaks when your code is expecting#save
to raise exceptions.#save
will return false on a failed write and populate anerrors
array. If you wish to raise exceptions on failed save attempts, use the#save!
method. -
Feature - Aws::Record - Adds logic to determine if
#save
and#save!
calls should useAws::DynamoDB::Client#put_item
orAws::DynamoDB::Client#update_item
, depending on which item attributes are marked as dirty.#put_item
calls are also made conditional on the key not existing, so accidental overwrites can be prevented. Old behavior of unconditional#put_item
calls can be done using theforce: true
parameter. -
Feature - Aws::Record - Separates the
#save
method into#save
and#save!
.#save!
will raise any errors that occur during persistence, while#save
will 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::Record
items 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
#query
and#scan
methods. Query and Scan results are surfaces as an enumerable collection ofAws::Record
items. -
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-record
gem. Includes basic table and item functionality for CRUD operations.