Added underscore to generated name's suffix
authorkaspersorensen <i.am.kasper.sorensen@gmail.com>
Tue, 26 Apr 2016 15:28:37 +0000 (08:28 -0700)
committerkaspersorensen <i.am.kasper.sorensen@gmail.com>
Tue, 26 Apr 2016 15:28:37 +0000 (08:28 -0700)
core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
core/src/test/java/org/apache/metamodel/schema/naming/DefaultColumnNamingStrategyTest.java

index e5288fe..d4d21dd 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Set;
  * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but\r
  * ensures that all column names are unique. When duplicate names are\r
  * encountered a number will be appended yielding column names like "name",\r
- * "name1", "name2" etc.\r
+ * "name_2", "name_3" etc.\r
  */\r
 public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {\r
 \r
@@ -47,7 +47,7 @@ public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
 \r
                 String newName = null;\r
                 for (int i = 2; !unique; i++) {\r
-                    newName = intrinsicName + i;\r
+                    newName = intrinsicName + '_' + i;\r
                     unique = names.add(newName);\r
                 }\r
                 return newName;\r
index c8c408b..a293939 100644 (file)
@@ -34,7 +34,7 @@ public class DefaultColumnNamingStrategyTest {
         try (final ColumnNamingSession session = namingStrategy.startColumnNamingSession()) {
             assertEquals("foo", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 0)));
             assertEquals("bar", session.getNextColumnName(new ColumnNamingContextImpl(null, "bar", 1)));
-            assertEquals("foo2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
+            assertEquals("foo_2", session.getNextColumnName(new ColumnNamingContextImpl(null, "foo", 2)));
         }
     }