diff --git a/lib/cdc/mongo/debezium_test.go b/lib/cdc/mongo/debezium_test.go index 5baa9c946..54bed5880 100644 --- a/lib/cdc/mongo/debezium_test.go +++ b/lib/cdc/mongo/debezium_test.go @@ -199,6 +199,7 @@ func (m *MongoTestSuite) TestMongoDBEventCustomer() { assert.Equal(m.T(), nestedData["object"], "foo") assert.Equal(m.T(), evtData[constants.DeleteColumnMarker], false) + assert.Equal(m.T(), evtData[constants.OnlySetDeleteColumnMarker], false) assert.Equal(m.T(), evt.GetExecutionTime(), time.Date(2022, time.November, 18, 6, 35, 21, 0, time.UTC)) assert.Equal(m.T(), "customers", evt.GetTableName()) @@ -246,8 +247,12 @@ func (m *MongoTestSuite) TestMongoDBEventCustomerBefore_NoData() { _, isOk := evtData[constants.UpdateColumnMarker] assert.False(m.T(), isOk) - _, isOk = evtData[constants.DeleteColumnMarker] + deletionFlag, isOk := evtData[constants.DeleteColumnMarker] assert.True(m.T(), isOk) + assert.True(m.T(), deletionFlag.(bool)) + deletionOnlyFlag, isOk := evtData[constants.OnlySetDeleteColumnMarker] + assert.True(m.T(), isOk) + assert.True(m.T(), deletionOnlyFlag.(bool)) assert.Equal(m.T(), evt.GetExecutionTime(), time.Date(2022, time.November, 18, 6, 35, 21, 0, time.UTC)) assert.Equal(m.T(), true, evt.DeletePayload()) @@ -296,10 +301,11 @@ func (m *MongoTestSuite) TestMongoDBEventCustomerBefore() { assert.False(m.T(), isOk) expectedKeyToVal := map[string]any{ - "_id": 1003, - constants.DeleteColumnMarker: true, - "first_name": "Robin", - "email": "robin@example.com", + "_id": 1003, + constants.DeleteColumnMarker: true, + constants.OnlySetDeleteColumnMarker: true, + "first_name": "Robin", + "email": "robin@example.com", } for expectedKey, expectedVal := range expectedKeyToVal { diff --git a/lib/cdc/util/relational_event_test.go b/lib/cdc/util/relational_event_test.go index 6dcbfb22f..3fa76102c 100644 --- a/lib/cdc/util/relational_event_test.go +++ b/lib/cdc/util/relational_event_test.go @@ -119,11 +119,15 @@ func TestGetDataTestInsert(t *testing.T) { deletionFlag, isOk := evtData[constants.DeleteColumnMarker] assert.True(t, isOk) assert.False(t, deletionFlag.(bool)) + deletionOnlyFlag, isOk := evtData[constants.OnlySetDeleteColumnMarker] + assert.True(t, isOk) + assert.False(t, deletionOnlyFlag.(bool)) _, isOk = evtData[constants.UpdateColumnMarker] assert.False(t, isOk) delete(evtData, constants.DeleteColumnMarker) + delete(evtData, constants.OnlySetDeleteColumnMarker) assert.Equal(t, after, evtData) evtData, err = schemaEventPayload.GetData(map[string]any{"pk": 1}, &kafkalib.TopicConfig{ @@ -141,11 +145,12 @@ func TestGetData_TestDelete(t *testing.T) { } expectedKeyValues := map[string]any{ - "id": int64(1004), - "first_name": "Anne", - "last_name": "Kretchmar", - "email": "annek@noanswer.org", - constants.DeleteColumnMarker: true, + "id": int64(1004), + "first_name": "Anne", + "last_name": "Kretchmar", + "email": "annek@noanswer.org", + constants.DeleteColumnMarker: true, + constants.OnlySetDeleteColumnMarker: true, } kvMap := map[string]any{"pk": 1004} @@ -214,11 +219,15 @@ func TestGetDataTestUpdate(t *testing.T) { deletionFlag, isOk := evtData[constants.DeleteColumnMarker] assert.True(t, isOk) assert.False(t, deletionFlag.(bool)) + deletionOnlyFlag, isOk := evtData[constants.OnlySetDeleteColumnMarker] + assert.True(t, isOk) + assert.False(t, deletionOnlyFlag.(bool)) _, isOk = evtData[constants.UpdateColumnMarker] assert.False(t, isOk) delete(evtData, constants.DeleteColumnMarker) + delete(evtData, constants.OnlySetDeleteColumnMarker) assert.Equal(t, after, evtData) evtData, err = schemaEventPayload.GetData(kvMap, &kafkalib.TopicConfig{