mirror of https://github.com/apache/openjpa.git
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.
This commit is contained in:
parent
8f96a5bd79
commit
6861dd1d02
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.jdbc.identifier;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
|
||||
|
||||
/**
|
||||
* 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 ColumnIdentifierRule extends DBIdentifierRule {
|
||||
|
||||
public ColumnIdentifierRule(Set<String> reservedWords) {
|
||||
super(DBIdentifierType.COLUMN, reservedWords);
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
|
Loading…
Reference in New Issue