Repository: typedorm/typedorm (ts)

Issue:
Incorrect update expression generated for entity with @TransformToDynamo decorator
Custom transform done using `@TransformToDynamo` is not properly applied when working performing simple updates.

Repro:

```typescript
@Entity({
...stuff
})
class Photo {

@AutoGenerateAttribute({
  strategy: UUID4
})
@TransformToDynamo(({value}: {value: Date}) =>
  moment(value, moment.ISO_8601).utc().format('yyyy-MM-DD')
)
updatedAt: Date
}
```

When updating above entity with,
```typescript
entityManager.update(Photo, {id: 1}, {updatedAt: new Date()})
```
generated update expression ignores custom transformation.
 


Pull request:
fix(core): update item with custom transforms
closes #154 

Patch:
diff --git a/packages/core/src/classes/expression/expression-input-parser.ts b/packages/core/src/classes/expression/expression-input-parser.ts
index e6a1057..cb13340 100644
--- a/packages/core/src/classes/expression/expression-input-parser.ts
+++ b/packages/core/src/classes/expression/expression-input-parser.ts
@@ -208,7 +208,10 @@ export class ExpressionInputParser {
             );
           } else {
             // fallback to default `SET` action based update
-            return new SetUpdate().setTo(attr, value);
+            return new SetUpdate().setTo(
+              attr,
+              attrValueOverrideMap[attr] || value
+            );
           }
         })
         // merge all expressions with matching action


Test patch:
diff --git a/packages/core/src/classes/transformer/__test__/dc-request-transformer.spec.ts b/packages/core/src/classes/transformer/__test__/dc-request-transformer.spec.ts
index 01cb449..262d474 100644
--- a/packages/core/src/classes/transformer/__test__/dc-request-transformer.spec.ts
+++ b/packages/core/src/classes/transformer/__test__/dc-request-transformer.spec.ts
@@ -475,6 +475,39 @@ test('transforms update item request', () => {
   });
 });
 
+// Issue: #154
+test('transforms update item request with custom transformation', () => {
+  const updatedItem = transformer.toDynamoUpdateItem(
+    Photo,
+    {
+      id: '123',
+      category: CATEGORY.KIDS,
+    },
+    {
+      createdAt: moment().subtract(2, 'days'),
+    }
+  );
+  expect(updatedItem).toEqual({
+    ExpressionAttributeNames: {
+      '#UE_createdAt': 'createdAt',
+      '#UE_updatedAt': 'updatedAt',
+    },
+    ExpressionAttributeValues: {
+      ':UE_createdAt': '2021-05-30',
+      ':UE_updatedAt': '1622530750',
+    },
+    Key: {
+      PK: 'PHOTO#KIDS',
+      SK: 'PHOTO#123',
+    },
+    ReturnConsumedCapacity: undefined,
+    ReturnValues: 'ALL_NEW',
+    TableName: 'test-table',
+    UpdateExpression:
+      'SET #UE_createdAt = :UE_createdAt, #UE_updatedAt = :UE_updatedAt',
+  });
+});
+
 test('transforms update item request respects custom transforms applied via class transformer', () => {
   const updatedItem = transformer.toDynamoUpdateItem(
     Photo,