You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by st...@apache.org on 2021/04/02 10:02:25 UTC
[openjpa] branch master updated: OPENJPA-1303 differentiate btw
COLUMN and COLUMN_DEF rules
This is an automated email from the ASF dual-hosted git repository.
struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git
The following commit(s) were added to refs/heads/master by this push:
new 6861dd1 OPENJPA-1303 differentiate btw COLUMN and COLUMN_DEF rules
6861dd1 is described below
commit 6861dd1d02751ae55ef64dd51f6808d044dc560d
Author: Mark Struberg <st...@apache.org>
AuthorDate: Fri Apr 2 12:01:02 2021 +0200
OPENJPA-1303 differentiate btw COLUMN and COLUMN_DEF rules
Column names and Column definitions (the types, e.g. VARCHAR(20) ) have
different rules. We now can properly specify both of em.
---
.../openjpa/jdbc/identifier/ColumnDefIdentifierRule.java | 5 +++--
...mnDefIdentifierRule.java => ColumnIdentifierRule.java} | 15 +++++----------
.../org/apache/openjpa/jdbc/identifier/DBIdentifier.java | 6 ++++++
.../java/org/apache/openjpa/jdbc/sql/DBDictionary.java | 9 ++++++---
4 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
index 6591659..1e9a9e1 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
@@ -32,8 +32,9 @@ import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
*/
public class ColumnDefIdentifierRule extends DBIdentifierRule {
- public ColumnDefIdentifierRule(Set<String> reservedWords) {
- super(DBIdentifierType.COLUMN, reservedWords);
+ public ColumnDefIdentifierRule() {
+ super();
+ setName(DBIdentifierType.COLUMN_DEFINITION.toString());
// Disable auto delimiting of column definition.
setCanDelimit(false);
}
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnIdentifierRule.java
similarity index 62%
copy from openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
copy to openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnIdentifierRule.java
index 6591659..cae84d2 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnDefIdentifierRule.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/ColumnIdentifierRule.java
@@ -23,18 +23,13 @@ import java.util.Set;
import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
/**
- * Default rule for column definition. This rule disables delimiting of
- * column definitions. Column definitions can be extremely tricky to
- * delimit correctly. Blindly delimiting them causes failures on most
- * databases. Where user defined types are concerned, generally they don't
- * need to be delimited and if so, they are more appropriately delimited
- * when they are specified.
+ * Default rule for column names.
+ * Column names which are forbidden as column names will get detected properly.
+ * Those reserved words might differ from the general reserved words.
*/
-public class ColumnDefIdentifierRule extends DBIdentifierRule {
+public class ColumnIdentifierRule extends DBIdentifierRule {
- public ColumnDefIdentifierRule(Set<String> reservedWords) {
+ public ColumnIdentifierRule(Set<String> reservedWords) {
super(DBIdentifierType.COLUMN, reservedWords);
- // Disable auto delimiting of column definition.
- setCanDelimit(false);
}
}
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java
index 255784a..05fd32b 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java
@@ -42,7 +42,13 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie
SCHEMA,
CATALOG,
DATABASE,
+ /**
+ * used for column names
+ */
COLUMN,
+ /**
+ * used for column type definition
+ */
COLUMN_DEFINITION,
SEQUENCE,
CONSTRAINT,
diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
index 5d73230..e4ae5bf 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
@@ -72,6 +72,7 @@ import javax.sql.DataSource;
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import org.apache.openjpa.jdbc.identifier.ColumnDefIdentifierRule;
+import org.apache.openjpa.jdbc.identifier.ColumnIdentifierRule;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
import org.apache.openjpa.jdbc.identifier.DBIdentifierRule;
@@ -610,9 +611,11 @@ public class DBDictionary
// Disable delimiting of column definition. DB platforms are very
// picky about delimiters in column definitions. Base column types
// do not require delimiters and will cause failures if delimited.
- DBIdentifierRule cdRule = new ColumnDefIdentifierRule(invalidColumnWordSet);
- cdRule.setCanDelimit(false);
- namingRules.put(cdRule.getName(), cdRule);
+ DBIdentifierRule columnDefinitionNamingRule = new ColumnDefIdentifierRule();
+ namingRules.put(columnDefinitionNamingRule.getName(), columnDefinitionNamingRule);
+
+ DBIdentifierRule columnNamingRule = new ColumnIdentifierRule(invalidColumnWordSet);
+ namingRules.put(columnNamingRule.getName(), columnNamingRule);
}
//////////////////////