forked from scanamo/scanamo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
RequestCondition
, introduce AttributeNamesAndValues
* **`RequestCondition` dynamo values become non-optional**: instead they can just be `DynamoObject.empty` * **New class `AttributeNamesAndValues`**: we often combine the different sources of attribute names/values in a request (eg, 'update' and 'condition') and there's no point in repeatedly writing code where names are combined, and then _values_ are combined - we always want to aggregate both at the same time, now supported with `AttributeNamesAndValues` * **New class `UpdateAndCondition`**: combines `UpdateExpression` & `Option[Condition]` - models the payload of both normal `UpdateItem` & transactional `Update` requests. * Using the [lambda syntax for Single Abstract Method (SAM) types](https://www.scala-lang.org/news/2.12.0/#lambda-syntax-for-sam-types) in the implementation of many typeclass instances of `ConditionExpression` and `QueryableKeyCondition` (eg `QueryableKeyCondition[KeyEquals[V]]`) makes the implementations much shorter. The 'values' on `RequestCondition` have been optional since `RequestCondition` was introduced with scanamo#31 in May 2016 - back then they were `attributeValues: Option[Map[String, AttributeValue]]`), and became `dynamoValues: Option[DynamoObject]` with scanamo#400 in May 2019. The values are probably 'optional' because there are certain DynamoDB condition expression functions (like `attribute_exists()`) that _don't_ take a value, so it was _reasonable_ for implementations like `ConditionExpression[AttributeExists]` to create instances of `RequestCondition` where `dynamoValues` was `None`. However, if we make `dynamoValues` non-optional, we can just supply `DynamoObject.empty` rather than `None`- and this allows us to simplify so much logic around combining the attribute values that come from different sources (eg as conditions are combined). * Introduce AttributeNamesAndValues and use UpdateExpression as a useful grouping
- Loading branch information
Showing
11 changed files
with
263 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.