Skip to content

Commit

Permalink
dev checkin. fix for firebird mixed case.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Feb 15, 2012
1 parent 89e53d0 commit eb7beaa
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 9 deletions.
Expand Up @@ -12,15 +12,15 @@ public FirebirdTriggerTemplate() {

functionInstalledSql = "select count(*) from rdb$functions where rdb$function_name = upper('$(functionName)')" ;
emptyColumnTemplate = "''" ;
stringColumnTemplate = "case when $(tableAlias).$(columnName) is null then '' else '\"' || sym_escape(substring($(tableAlias).$(columnName) from 1)) || '\"' end" ;
stringColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || sym_escape(substring($(tableAlias).\"$(columnName)\" from 1)) || '\"' end" ;
xmlColumnTemplate = null;
arrayColumnTemplate = null;
numberColumnTemplate = "case when $(tableAlias).$(columnName) is null then '' else '\"' || $(tableAlias).$(columnName) || '\"' end" ;
datetimeColumnTemplate = "case when $(tableAlias).$(columnName) is null then '' else '\"' || $(tableAlias).$(columnName) || '\"' end" ;
numberColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || $(tableAlias).\"$(columnName)\" || '\"' end" ;
datetimeColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || $(tableAlias).\"$(columnName)\" || '\"' end" ;
timeColumnTemplate = null;
dateColumnTemplate = null;
clobColumnTemplate = "case when $(tableAlias).$(columnName) is null then '' else '\"' || sym_escape(substring($(tableAlias).$(columnName) from 1)) || '\"' end" ;
blobColumnTemplate = "case when $(tableAlias).$(columnName) is null then '' else '\"' || sym_hex($(tableAlias).$(columnName)) || '\"' end" ;
clobColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || sym_escape(substring($(tableAlias).\"$(columnName)\" from 1)) || '\"' end" ;
blobColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || sym_hex($(tableAlias).\"$(columnName)\") || '\"' end" ;
wrappedBlobColumnTemplate = null;
booleanColumnTemplate = null;
triggerConcatCharacter = "||" ;
Expand Down
Expand Up @@ -390,7 +390,7 @@ protected void prefixConfigDatabase(Database targetTables) {

Table[] tables = targetTables.getTables();

boolean storesUpperCaseIdentifiers = platform.getSqlTemplate()
boolean storesUpperCaseIdentifiers = platform
.isStoresUpperCaseIdentifiers();
for (Table table : tables) {
String name = String.format("%s%s", prefix, table.getName());
Expand Down
Expand Up @@ -105,6 +105,8 @@ public abstract class AbstractDatabasePlatform implements IDatabasePlatform {
protected String defaultCatalog;

protected Boolean storesUpperCaseIdentifiers;

protected Boolean storesMixedCaseIdentifiers;

public AbstractDatabasePlatform() {
setDelimitedIdentifierModeOn(true);
Expand Down Expand Up @@ -436,6 +438,13 @@ public List<Column> getLobColumns(Table table) {
}
return lobColumns;
}

public boolean isStoresMixedCaseQuotedIdentifiers() {
if (storesMixedCaseIdentifiers == null) {
storesMixedCaseIdentifiers = getSqlTemplate().isStoresMixedCaseQuotedIdentifiers();
}
return storesMixedCaseIdentifiers;
}

public boolean isStoresUpperCaseIdentifiers() {
if (storesUpperCaseIdentifiers == null) {
Expand Down Expand Up @@ -470,7 +479,7 @@ public Database readDatabaseFromXml(String filePath, boolean alterCaseToMatchDat
Database database = new DatabaseIO().read(reader);
IOUtils.closeQuietly(reader);
if (alterCaseToMatchDatabaseDefaultCase) {
boolean storesUpperCase = getSqlTemplate().isStoresUpperCaseIdentifiers();
boolean storesUpperCase = isStoresUpperCaseIdentifiers();
Table[] tables = database.getTables();
for (Table table : tables) {
if (!FormatUtils.isMixedCase(table.getName())) {
Expand Down
Expand Up @@ -211,5 +211,7 @@ public Object[] getObjectValues(BinaryEncoding encoding, Table table, String[] c
public String scrubSql(String sql);

public boolean isStoresUpperCaseIdentifiers();

public boolean isStoresMixedCaseQuotedIdentifiers();

}
Expand Up @@ -96,6 +96,8 @@ public <T, W> Map<T, W> query(String sql, String keyCol, String valueCol, Object
public boolean supportsGetGeneratedKeys();

public boolean isStoresUpperCaseIdentifiers();

public boolean isStoresMixedCaseQuotedIdentifiers();

public long insertWithGeneratedKey(final String sql, String column, final String sequenceName,
final Object[] args, final int[] types);
Expand Down
Expand Up @@ -1271,5 +1271,5 @@ public String determineSchemaOf(Connection connection, String schemaPattern, Tab
close(columnData);
close(tableData);
}
}
}
}
Expand Up @@ -41,6 +41,7 @@
import org.jumpmind.db.platform.DatabaseMetaDataWrapper;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.IDdlBuilder;
import org.jumpmind.util.FormatUtils;

/*
* The Jdbc Model Reader for Firebird.
Expand Down Expand Up @@ -424,6 +425,9 @@ protected String getTableNamePattern(String tableName) {
* get back column names for more than one table. Example:
* DatabaseMetaData.metaData.getColumns(null, null, "SYM\\_NODE", null)
*/
if (FormatUtils.isMixedCase(tableName)) {
tableName = String.format("\"%s\"", tableName);
}
return tableName.replaceAll("\\_", "\\\\_");
}

Expand Down
Expand Up @@ -514,6 +514,14 @@ public String execute(Connection con) throws SQLException {
}
});
}

public boolean isStoresMixedCaseQuotedIdentifiers() {
return execute(new IConnectionCallback<Boolean>() {
public Boolean execute(Connection con) throws SQLException {
return con.getMetaData().storesMixedCaseQuotedIdentifiers();
}
});
}

public boolean isStoresUpperCaseIdentifiers() {
return execute(new IConnectionCallback<Boolean>() {
Expand Down
@@ -1,4 +1,4 @@
test.root=h2
test.root=firebird
test.client=h2

mysql.db.driver=com.mysql.jdbc.Driver
Expand Down

0 comments on commit eb7beaa

Please sign in to comment.