-
Notifications
You must be signed in to change notification settings - Fork 71
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
unexpected results when adding optional attributes to a projection expression #464
Comments
Thanks @anatolzak! I will take a look at this to better understand what's going on under the hood, thanks for sending it over, hope to reply back soon! |
@anatolzak Firstly, thank you very much for the example repo; it helped me quickly jump into this ticket! Is it safe to assume the behavior you're expecting (in the specific case of your example) is to have an empty object returned? |
@tywalch glad the repo was helpful! And yes, I would expect an empty object |
- [Issue #464](#464); When specifing return attributes on retrieval methods, ElectroDB would unexpectly return null or missing values if the options chosen resulted in an empty object being returned. This behavor could be confused with no results being found. ElectroDB now returns the empty object in these cases. ### Added - ElectroDB Error objects no contain a `params()` method. If your operation resulted in an error thrown by the DynamoDB client, you can call the `params()` method to get the compiled parameters sent to DynamoDB. This can be helpful for debugging. Note, that if the error was thrown prior to parameter creation (validation errors, invalid query errors, etc) then the `params()` method will return the value `null`.
* ### Fixed - [Issue #464](#464); When specifing return attributes on retrieval methods, ElectroDB would unexpectly return null or missing values if the options chosen resulted in an empty object being returned. This behavor could be confused with no results being found. ElectroDB now returns the empty object in these cases. ### Added - ElectroDB Error objects no contain a `params()` method. If your operation resulted in an error thrown by the DynamoDB client, you can call the `params()` method to get the compiled parameters sent to DynamoDB. This can be helpful for debugging. Note, that if the error was thrown prior to parameter creation (validation errors, invalid query errors, etc) then the `params()` method will return the value `null`. * Adds type tests, fixes lacking imports * Cleans up approach to type test imports
Describe the bug
If your entity has an optional attribute and you specify this attribute in the attributes selection, ElectroDB behaves as follows: If the item in DynamoDB does not include the optional attribute:
get
operation ({ data: null }
).query
operation ({ data: [], cursor: null }
).{ data: [null], unprocessed: [] }
).Here is an example illustrating the differences in the query operation when specifying optional fields in the attributes (the
name
attribute is defined as optional at the Entity level):Here is an example illustrating the differences in the
get
operation when specifying optional fields in the attributes:Here is an example illustrating the differences in the
batchGet
operation when specifying optional fields in the attributes:ElectroDB Version
3.0.1
ElectroDB Playground Link
Not relevant, as the issue occurs after ElectroDB receives the response from DynamoDB, and ElectroDB doesn't return all the expected items.
I created a minimal reproducible repository: https://github.com/anatolzak/electrodb-optional-attributes-bug. Just run
npm install
and./run.sh
.Entity/Service Definitions
Expected behavior
Items should not be excluded from the results of read operations if they don't contain optional attributes.
The text was updated successfully, but these errors were encountered: