-
Notifications
You must be signed in to change notification settings - Fork 19
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
anyway to view produced request from fluent apI? #210
Comments
Currently, there is no way to view the actual DynamoDB expression being generated. This feature has been on our agenda since the start, but implementing it is challenging due to some performance-oriented design choices we made. Regarding the failure of the first two requests due to non-existent fields, you should consider using fallback values. These values get translated into the var defaultQuantity = 0;
UpdateItem()
.WithPrimaryKey(inventoryItem.PartitionKey,inventoryItem.SortKey)
.On(x => x.Quantity).Increment(defaultQuantity, inventoryItem.Quantity)
UpdateItem()
.WithPrimaryKey(inventoryItem.PartitionKey,inventoryItem.SortKey)
.On(x => x.Quantity).AssignSum(x => x.Quantity, defaultQuantity, inventoryItem.Quantity) In this example, I've added the Generally, if an operation relies on a value already stored in DynamoDB, it's recommended to provide a fallback value to avoid failure. For such situations, seek overloads with |
thank you for response. worked perfect. sorry should've split into two posts for anyone searching for same thing. Did know could do that, to get "if_not_exists()" One reasons wishing to knowing expression being generated, was unsure on which SET or ADD. was being used backend. I assume it is SET. as using second solution from this stackoverflow question . I never thought about asking if I can force selection. with something, like .BySET .ByADD. eg .On(x => x.Quantity).Increment(inventoryItem.Quantity).ByADD Though I have no need for it myself as can use "if_not_exists()." and I don't think ADD has many other uses. At first I thought AssignSum and Increment one did SET and other ADD but assume they both do same from reading #100 For that feature on expression being generated could make for non production only (as 90% would only use for debug I think? ) or even standalone one that just output expression ? ( btw , not asking for or needing either, just ideas. I have not much clue on working. did look but to deep for me hah) |
Indeed, the operation uses SET for addition. I'm not sure why the StackOverflow answer suggests ADD as the preferred method when the AWS documentation, linked in that answer, advises using SET over ADD in general:
You're right. There are no specific uses for updating numbers that are possible with ADD but not with SET.
Correct, As for generating a debug-only output, this would indeed be a beneficial feature. However, it's a challenge to adapt our existing code to accommodate this function without impacting the performance of production use cases. Ensuring the code remains consistent between production and debug outputs is essential, which adds to the complexity of this task. At the moment, I can't commit to a timeline as to when we could look into adding this feature. However, we're very open to contributions, so if you or someone else wants to give it a shot and submit a pull request, we'd be more than happy to review it. |
Perfect ty. and sorry my code way to messy to consider it lol |
One way of hooking up to generated request details is by setting the custom HttpClientFactory that returns the HttpClient that accesses the request content (say in DelegatingHandler). |
is there any way to see what is being produced?
I tried mess about with IUpdateEntityRequestBuilder but could not work it out.
The main reason I have three requests below but first two fail if does not exist as field does not exist. wish to debug but can't see if something I'm doing or if there would be another way i could be make the fluent api to produce different request with SET / ADD, But at moment, don't know how see what my changes make will effect it.
UpdateItem()
.WithPrimaryKey(inventoryItem.PartitionKey,inventoryItem.SortKey)
.On(x => x.Quantity).Increment(inventoryItem.Quantity)
UpdateItem()
.WithPrimaryKey(inventoryItem.PartitionKey,inventoryItem.SortKey)
.On(x => x.Quantity).AssignSum(x => x.Quantity, inventoryItem.Quantity)
UpdateItem()
.WithPrimaryKey(inventoryItem.PartitionKey,inventoryItem.SortKey)
.On(x => x.Quantity).Assign(x => x.Quantity, inventoryItem.Quantity)
.WithReturnValues(ReturnValues.AllNew)
The text was updated successfully, but these errors were encountered: