Skip to content

Commit

Permalink
fix(events): makes ApproximateCreationDateTime optional in dynamo eve…
Browse files Browse the repository at this point in the history
…nt stream record (#891)

closes #889
  • Loading branch information
jfkisafk authored Jun 6, 2024
1 parent 1cf868c commit d03bbc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lambda-events/src/event/dynamodb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ pub struct UserIdentity {
#[serde(rename_all = "camelCase")]
pub struct StreamRecord {
/// The approximate date and time when the stream record was created, in UNIX
/// epoch time (http://www.epochconverter.com/) format.
/// epoch time (http://www.epochconverter.com/) format. Might not be present in
/// the record: https://github.com/awslabs/aws-lambda-rust-runtime/issues/889
#[serde(rename = "ApproximateCreationDateTime")]
#[serde(with = "float_unix_epoch")]
#[serde(default)]
pub approximate_creation_date_time: DateTime<Utc>,
/// The primary key attribute(s) for the DynamoDB item that was modified.
#[serde(deserialize_with = "deserialize_lambda_dynamodb_item")]
Expand Down Expand Up @@ -274,5 +276,7 @@ mod test {
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: EventRecord = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
let date = Utc.timestamp_micros(0).unwrap(); // 1970-01-01T00:00:00Z
assert_eq!(date, reparsed.change.approximate_creation_date_time);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"recordFormat":"application/json",
"tableName":"examples",
"dynamodb":{
"ApproximateCreationDateTime":1649809356015,
"Keys":{
"id":{
"S":"00000000-0000-0000-0000-000000000000"
Expand Down

0 comments on commit d03bbc4

Please sign in to comment.