Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDBMapper not supporting new Condition Expressions? #534

Closed
derjust opened this issue Oct 15, 2015 · 7 comments
Closed

DynamoDBMapper not supporting new Condition Expressions? #534

derjust opened this issue Oct 15, 2015 · 7 comments
Labels
feature-request A feature should be added or improved.

Comments

@derjust
Copy link

derjust commented Oct 15, 2015

Hi AWS!

I'm using DynamoDB via the DynamoDBMapper throughout our application.
Recently I wanted to add a Condition Expression to a PUT operation - looks like DynamoDBSaveExpression only supports the old/deprecated Expected style?
Or is there another class to be used?
Wondering mostly because the new Condition Expression seem to exist on DynamoDBDeleteExpression?!

@zhangzhx
Copy link
Contributor

zhangzhx commented Nov 2, 2015

You can use Condition Operator together with Expected as a replacement of Condition Expression. We'll consider adding Condition Expression in the future release if more customers have the same requirement.

@manikandanrs manikandanrs added the feature-request A feature should be added or improved. label Nov 27, 2015
@jakeab
Copy link

jakeab commented Jan 19, 2016

I am also running into this inconsistency. I am new to DynamoDB and this took some digging to sus out. I wish to use the < and > operators to make a conditional save via the mapper. The SaveExpression class should support the non-deprecated parameters.

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBSaveExpression.html

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html

Thanks,
Jake

@zhangzhx zhangzhx self-assigned this Jan 21, 2016
@zhangzhx
Copy link
Contributor

Hello Jake,

The reason we are not supporting this feature is because it is not as simple as supporting the Expected Map + Condition Operator. When you enable versioning or auto generatinging keys, we'll merge the conditions user provided with an internal conditions which is currently implemented using Expected Map.

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapper.java#L978-L983

It is easy to merge conditions using the less powerful Expected Map, however merging the Condition Expression is not unless we write an expression parser. So we currently are not planning to support this feature until we have a better reason. Take a look at the onVersionAttribute() and onAutoGenerateAssignableKey() methods and you will have a better understanding. Sorry for the inconvenient.

@jakeab
Copy link

jakeab commented Feb 23, 2016

Hi again,

Thanks for your response.

This seems inconsistent to me, because this works on the delete operation: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBDeleteExpression.html

My use case is similar for save and delete. I have stored date strings and want to only update or delete a record if a given date is newer than the stored date. I can do this with the delete API. Without this feature I do not think I can do it with the save API.

Without digging into the details of the feature you linked, I somewhat understand this might be difficult to implement alongside another feature. I am not sure what sort of case will meet the bar to get this done, though--I am providing what seems to be a valid use case. Perhaps you can simply raise an UnsupportedOperationException if end users try to use both features combined.

Am I limited at this point to making a load call to check the value before using save? The concurrency might be good enough for my use case, but I would prefer the strong consistency of the single operation.

Thanks again,
Jake

@ryonday
Copy link

ryonday commented Jun 19, 2017

Please implement this. The fact that it's a Map<String, ExpectedAttributeValue> means that you cannot implement multiple conditions on a single attribute. This is exceptionally painful.

@agudian
Copy link

agudian commented Nov 13, 2018

My use case is similar for save and delete. I have stored date strings and want to only update or delete a record if a given date is newer than the stored date. I can do this with the delete API. Without this feature I do not think I can do it with the save API.

Same here.

And as the expected style is highlighted as deprecated in the documentation, it would only make sense to support the (much more versatile) alternative in the DynamoDBMapper as well. And it wouldn't even need to be a String condition that needs to be parsed: in the mapper world, you could allow building the conditions in an API style as well (which avoids the need to create an expression parser). A simple approach will do, for a lot of use cases.

@debora-ito
Copy link
Member

Hey @derjust @jakeab @ryonday @agudian,

the SDK team has reviewed the feature request list for V1, and since they're concentrating efforts on V2 new features they decided to not implement this one in V1. It's still being considered for the DynamoDB Mapper refactor in V2, see the referenced issue above. I'll go ahead and close this one.

Please feel free to comment on the V2 issue with your use case, and reach out if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

7 participants