Skip to content

Support for custom Update expressions #137

Closed
@lsglick

Description

@lsglick

Occasionally we would like to use Update expressions for more advanced updates than seem to be available when modifying an attribute and using the existing #update methods. We particularly need this for transactions.

For example:

  • Use ADD/DELETE to modify items in a set
  • Use if_not_exists function to control behavior when multiple updates occur in succession
  • Accumulate a value during a transaction (similar to increment! but in a transaction)

It would be great if there were a way to do this in special cases while still largely taking advantages of the conveniences afforded by this SDK.

Unfortunately, update_expression is always set directly with no opportunity to override it.

E.g. Item Operations:
https://github.com/aws/aws-sdk-ruby-record/blob/92e0070eea16698e23be8e31d3a36e681dc079e9/lib/aws-record/record/item_operations.rb#L609

E.g. Transactions:
https://github.com/aws/aws-sdk-ruby-record/blob/92e0070eea16698e23be8e31d3a36e681dc079e9/lib/aws-record/record/transactions.rb#L294

Some potential ideas:

  • If update_expression is passed in opts, use it instead of a generated one.
  • If update_expression is passed in opts, merge it with the generated one (might need to combine with the generated SET/REMOVE clauses)
  • A way to pass-through raw update clauses to Aws::Record::Transactions.transact_write that only set the minimal key/table rather than the full transformation (similar to delete).
  • A way to generate more raw actions similar to #transact_check_expression.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions