Skip to content

Commit

Permalink
0000904: DbExport does not respect the compatible setting for data
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Nov 9, 2012
1 parent a60f982 commit 65f2765
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 2 deletions.
Expand Up @@ -44,6 +44,7 @@
import org.jumpmind.db.model.Database;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.DdlBuilderFactory;
import org.jumpmind.db.platform.DmlStatementFactory;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.IDdlBuilder;
import org.jumpmind.db.platform.JdbcDatabasePlatformFactory;
Expand Down Expand Up @@ -211,7 +212,8 @@ protected void writeTable(final WriterWrapper writerWrapper, Table table, String

if (!noData) {
if (sql == null) {
sql = platform.createDmlStatement(DmlType.SELECT_ALL, table).getSql();
sql = DmlStatementFactory.createDmlStatement(compatible
.toString().toLowerCase(), DmlType.SELECT_ALL, table).getSql();
}

platform.getSqlTemplate().query(sql, new ISqlRowMapper<Object>() {
Expand Down
@@ -1,3 +1,23 @@
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* 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.jumpmind.db.platform;

import org.jumpmind.db.platform.db2.Db2DdlBuilder;
Expand Down
@@ -0,0 +1,60 @@
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* 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.jumpmind.db.platform;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.oracle.OracleDmlStatement;
import org.jumpmind.db.platform.postgresql.PostgreSqlDmlStatement;
import org.jumpmind.db.sql.DmlStatement;
import org.jumpmind.db.sql.DmlStatement.DmlType;

final public class DmlStatementFactory {

private DmlStatementFactory() {
}

public static DmlStatement createDmlStatement(String databaseName, DmlType dmlType, Table table) {
return createDmlStatement(databaseName, dmlType, table.getCatalog(), table.getSchema(),
table.getName(), table.getPrimaryKeyColumns(), table.getColumns(), null);
}

public static DmlStatement createDmlStatement(String databaseName, DmlType dmlType,
String catalogName, String schemaName, String tableName, Column[] keys,
Column[] columns, boolean[] nullKeyValues) {
IDdlBuilder ddlBuilder = DdlBuilderFactory.createDdlBuilder(databaseName);
if (DatabaseNamesConstants.ORACLE.equals(databaseName)) {
return new OracleDmlStatement(dmlType, catalogName, schemaName, tableName, keys,
columns, ddlBuilder.getDatabaseInfo().isDateOverridesToTimestamp(), ddlBuilder
.getDatabaseInfo().getDelimiterToken(), nullKeyValues);
} else if (DatabaseNamesConstants.POSTGRESQL.equals(databaseName)) {
return new PostgreSqlDmlStatement(dmlType, catalogName, schemaName, tableName, keys,
columns, ddlBuilder.getDatabaseInfo().isDateOverridesToTimestamp(), ddlBuilder
.getDatabaseInfo().getDelimiterToken(), nullKeyValues);
} else {
return new DmlStatement(dmlType, catalogName, schemaName, tableName, keys, columns,
ddlBuilder.getDatabaseInfo().isDateOverridesToTimestamp(), ddlBuilder
.getDatabaseInfo().getDelimiterToken(), nullKeyValues);
}

}

}
Expand Up @@ -96,7 +96,7 @@ public <T> ISqlReadCursor<T> queryForCursor(String sql, ISqlRowMapper<T> mapper)
}

public List<Row> query(String sql) {
return query(sql, (Object[]) null, (int[]) null);
return query(sql, (Object[])null, (int[]) null);
}

public <T> List<T> query(String sql, ISqlRowMapper<T> mapper, Object... args) {
Expand Down

0 comments on commit 65f2765

Please sign in to comment.