-
Notifications
You must be signed in to change notification settings - Fork 868
Implement DynamoDbFlatten annotation #3833
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
base: development
Are you sure you want to change the base?
Implement DynamoDbFlatten annotation #3833
Conversation
add new attribute and update write item flow fix flattened properties issue
@@ -181,6 +181,35 @@ public DynamoDBPolymorphicTypeAttribute(string typeDiscriminator, | |||
} | |||
} | |||
|
|||
/// <summary> | |||
/// Indicates that the properties of the decorated field or property type should be "flattened" | |||
/// into the top-level attributes of the DynamoDB item. When applied, all public properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they always flattened to "top-level attributes" or in the case of multi-nested structure the attributes are flattened to the parent structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attributes are flattened to the parent structure
@@ -390,29 +390,53 @@ private void PopulateInstance(ItemStorage storage, object instance, DynamoDBFlat | |||
|
|||
using (flatConfig.State.Track(document)) | |||
{ | |||
foreach (PropertyStorage propertyStorage in storageConfig.AllPropertyStorage) | |||
foreach (PropertyStorage propertyStorage in storageConfig.Properties) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the switch from AllPropertyStorage
to Properties
?
/// </para> | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = true, AllowMultiple = false)] | ||
public sealed class DynamoDBFlattenAttribute : DynamoDBAttribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if a POCO has this attribute and the POCO is used in a collection property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should only applies to single nested objects – not to collections, and this behavior is consistent with Java SDK. The only collection that will support flatten are Map<String, String>, but this is a new annotation @DynamoDbFlatten that is proposed to be added in the Java SDK.
Is there an ask for this feature or is this parity feature with the Java SDK? |
this is for feature parity with Java SDK |
Implement DynamoDbFlatten annotation
Description
Introduce the [DynamoDbFlatten] attribute, enabling developers to flatten complex nested types into their parent objects in DynamoDB, mirroring the behavior of Java SDK’s @DynamoDbFlattenDynamoDB Object Mapping. This allows for simpler, flat table schemas while maintaining clean object models in code.
Java DynamoDbFlatten
Motivation and Context
Testing
Integration test added
Unit test to be added for internal methods
Screenshots (if appropriate)
Types of changes
Checklist
License