Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

DBZ-8224 allow field name without topic qualifier #90

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ private static FieldNameFilter createFilter(String fieldList, boolean include) {
if (parts.length == 2 && parts[0].equals(topicName) && parts[1].equals(fieldName)) {
return include;
}
if (parts.length == 1 && parts[0].equals(fieldName)) {
return include;
}
}
return !include;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.debezium.connector.jdbc.filter;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import io.debezium.connector.jdbc.filter.FieldFilterFactory.FieldNameFilter;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class FieldFilterFactoryTest {

@Test
public void testFullyQualifiedFilter() {
FieldNameFilter filter = FieldFilterFactory.createFieldFilter("mytopic:myfield,mytopic2:myfield2", null);
assertTrue(filter.matches("mytopic", "myfield"), "matchees first item");
assertTrue(filter.matches("mytopic2", "myfield2"), "matchees second item");
assertFalse(filter.matches("mytopic3", "myfield"), "doesnt match when topic is different");
assertFalse(filter.matches("mytopic", "myfield3"), "doesnt match when field is different");
}

@Test
public void testUnqualifiedFilter() {
FieldNameFilter filter = FieldFilterFactory.createFieldFilter("myfield,myfield2", null);
assertTrue(filter.matches("mytopic", "myfield"), "matchees first item");
assertTrue(filter.matches("mytopic3", "myfield"), "matches first field in another topic");
assertTrue(filter.matches("mytopic2", "myfield2"), "matchees second item");
assertFalse(filter.matches("mytopic", "myfield3"), "doesnt match when field is different");
}

}
Loading