DynamoDB Autogenerated Update Expression Is Too Large
- Lingua principale
- Java
- Stelle
- 2.6k
- Fork
- 1k
- Merge medio
- 2g 9h
- PR unite (30g)
- 51
Descrizione
### Describe the bug
When generating update expressions via enhanced client tables, every name and value in the name and value maps are set to the name of their corresponding field prefixed by `"AMZN_MAPPED_"`. This causes problems when the number of attributes grows large. Changing the names of the fields on the class is not a suitable solution because it breaks readability of the code. Further, changing the names of the attributes in the dynamo table is not a suitable solution because that will require refactoring all services that interact with the table and may require migrating the table.
Consider the class below:
```
@Data
@DynamoDbBean
@NoArgsConstructor
@AllArgsConstructor
public class MyBean {
@Getter(onMethod_ = @DynamoDbPartitionKey)
private int id;
private String stringField;
private Integer integerField;
}
```
### Expected Behavior
Performing an `updateItem` on a `DynamoDbTable` with an instance of `MyBean` results in the following, minified update expression:
`SET #n0 = :v0, #n1 = :v1`
with a name map:
`#n0 -> stringField, #n1 -> integerField`
and with a value map:
`:v0 -> , :v1 -> `
### Current Behavior
Performing an `updateItem` on a `DynamoDbTable` with an instance of `MyBean` results in the following update expression, which is too large in some applications:
`SET #AMZN_MAPPED_stringField = :AMZN_MAPPED_stringField, #AMZN_MAPPED_integerField = :AMZN_MAPPED_integerField`
with a name map:
`#AMZN_MAPPED_stringField -> stringField, #AMZN_MAPPED_integerField -> integerField`
and with a value map:
`:AMZN_MAPPED_stringField -> , :AMZN_MAPPED_integerField -> `
### Reproduction Steps
Create a `DynamoDbBean` with a large number of fields. Create an instance of that bean. Perform a update item request using a `DynamoDbTable` from the enhanced client. The size of the item may be well within the limits of DynamoDB, but the update expression is too large to properly update it.
### Possible Solution
Minify the names of fields when creating the update expression.
### Additional Information/Context
I'm filing this as a bug since it's technically possible for this to break production code given that one is using the ignoreNulls option if some of null values on the bean are set for the first time. If this is better suited for a feature request, let me know and I will recreate it as such.
### AWS Java SDK version used
2.20.157
### JDK version used
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190
### Operating System and version
Windows 10 Home - 22H2
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia tracciando il percorso di DynamoDbTable.updateItem nell'enhanced client e il modo in cui genera le espressioni di aggiornamento, le mappe dei nomi e le mappe dei valori, prestando attenzione all'opzione ignoreNulls. Riproduci il caso DynamoDbBean di grandi dimensioni dell'issue e verifica che gli aggiornamenti completati utilizzino placeholder compatti, preservando le corrispondenze dei campi e i valori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100