dev-donghwan commented on code in PR #4618:
URL: https://github.com/apache/flink-cdc/pull/4618#discussion_r4553972422
##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-postgres/src/test/java/org/apache/flink/cdc/connectors/postgres/source/PostgresEventDeserializerTest.java:
##########
@@ -50,4 +77,80 @@ void testNullBeforeThrowsNpeWithReplicaIdentityHint() throws
Exception {
.hasMessageContaining("Before data is null")
.hasMessageContaining("REPLICA IDENTITY FULL");
}
+
+ @Test
+ void testUpdateEmitsUpdateEventInAllMode() throws Exception {
+ PostgresEventDeserializer deserializer =
+ new PostgresEventDeserializer(DebeziumChangelogMode.ALL);
+
+ List<Event> events =
+ deserialize(deserializer, buildUpdateRecord(row(1, "spare"),
row(1, "scooter")));
+
+ assertThat(events).hasSize(1);
+ DataChangeEvent event = (DataChangeEvent) events.get(0);
+ assertThat(event.op()).isEqualTo(OperationType.UPDATE);
+ assertThat(event.tableId()).isEqualTo(TableId.tableId("inventory",
"products"));
+ assertThat(event.before()).isNotNull();
+ assertThat(event.before().getInt(0)).isEqualTo(1);
+ assertThat(event.before().getString(1).toString()).isEqualTo("spare");
+ assertThat(event.after().getInt(0)).isEqualTo(1);
+ assertThat(event.after().getString(1).toString()).isEqualTo("scooter");
+ }
+
+ @Test
+ void testUpdateEmitsReplaceEventInUpsertMode() throws Exception {
Review Comment:
Done in `testUpsertModeWithReplicaIdentityDefault`. A PK-changing UPDATE is
emitted as a DELETE of the old key (whose before image carries only the key, as
expected with REPLICA IDENTITY DEFAULT) followed by an INSERT of the new key.
This case also revealed the TOAST gap mentioned in the other thread, so thanks
for asking for it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]