You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2019/01/29 00:04:30 UTC
[geode] branch feature/GEODE-6291 updated: getColumnNameForField
now compares the pdx name to the jdbc name instead of only looking at the
pdx names
This is an automated email from the ASF dual-hosted git repository.
dschneider pushed a commit to branch feature/GEODE-6291
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-6291 by this push:
new a32a206 getColumnNameForField now compares the pdx name to the jdbc name instead of only looking at the pdx names
a32a206 is described below
commit a32a20675e34226d84462d44ae677b1ea957d65a
Author: Darrel Schneider <ds...@pivotal.io>
AuthorDate: Mon Jan 28 16:03:39 2019 -0800
getColumnNameForField now compares the pdx name to the jdbc name
instead of only looking at the pdx names
---
.../jdbc/internal/configuration/RegionMapping.java | 6 +++++-
.../connectors/jdbc/internal/RegionMappingTest.java | 18 ++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/configuration/RegionMapping.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/configuration/RegionMapping.java
index 79ef582..6f28904 100644
--- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/configuration/RegionMapping.java
+++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/configuration/RegionMapping.java
@@ -193,9 +193,13 @@ public class RegionMapping implements CacheElement {
if (exactMatch != null) {
return exactMatch.getJdbcName();
}
+ exactMatch = getFieldMappingByJdbcName(fieldName);
+ if (exactMatch != null) {
+ return exactMatch.getJdbcName();
+ }
FieldMapping inexactMatch = null;
for (FieldMapping fieldMapping : getFieldMappings()) {
- if (fieldMapping.getPdxName().equalsIgnoreCase(fieldName)) {
+ if (fieldMapping.getJdbcName().equalsIgnoreCase(fieldName)) {
if (inexactMatch != null) {
throw new JdbcConnectorException(
"Multiple columns matched the pdx field \"" + fieldName + "\".");
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/RegionMappingTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/RegionMappingTest.java
index 688e1ab..4dd441f 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/RegionMappingTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/RegionMappingTest.java
@@ -124,9 +124,9 @@ public class RegionMappingTest {
mapping = new RegionMapping(null, pdxClassName, null, null, null, null, null);
mapping.addFieldMapping(new FieldMapping("f1", null, "c1", null, false));
mapping.addFieldMapping(
- new FieldMapping(pdxFieldName.toLowerCase(), null, columnName, null, false));
+ new FieldMapping("", null, pdxFieldName.toLowerCase(), null, false));
mapping.addFieldMapping(
- new FieldMapping(pdxFieldName.toUpperCase(), null, columnName, null, false));
+ new FieldMapping("", null, pdxFieldName.toLowerCase(), null, false));
expectedException.expect(JdbcConnectorException.class);
expectedException
.expectMessage("Multiple columns matched the pdx field \"" + pdxFieldName + "\".");
@@ -146,14 +146,24 @@ public class RegionMappingTest {
}
@Test
+ public void getColumnNameForFieldReturnsColumnNameWhenMappedExactlyToJdbcName() {
+ String pdxClassName = "pdxClassName";
+ String pdxFieldName = "pdxFieldName";
+ mapping = new RegionMapping(null, pdxClassName, null, null, null, null, null);
+ mapping.addFieldMapping(new FieldMapping("", null, pdxFieldName, null, false));
+
+ assertThat(mapping.getColumnNameForField(pdxFieldName)).isEqualTo(pdxFieldName);
+ }
+
+ @Test
public void getColumnNameForFieldReturnsColumnNameWhenMappedInexactly() {
String pdxClassName = "pdxClassName";
- String columnName = "columnName";
String pdxFieldName = "pdxFieldName";
+ String columnName = pdxFieldName.toLowerCase();
mapping = new RegionMapping(null, pdxClassName, null, null, null, null, null);
mapping.addFieldMapping(new FieldMapping("f1", null, "c1", null, false));
mapping.addFieldMapping(
- new FieldMapping(pdxFieldName.toLowerCase(), null, columnName, null, false));
+ new FieldMapping("", null, columnName, null, false));
assertThat(mapping.getColumnNameForField(pdxFieldName)).isEqualTo(columnName);
}