Skip to content

Commit

Permalink
fix for "Column name not exported with double quotes"
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/jailer/code/trunk@1129 3dd849cd-670e-4645-a7cd-dd197c8d0e81
  • Loading branch information
rwisser committed Dec 27, 2016
1 parent 3cbac5d commit e8e956f
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 57 deletions.
1 change: 1 addition & 0 deletions releasenotes-dbeauty.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2.8.1
- Data Browser has been improved.
- Bug fix for "Column name not exported with double quotes" https://sourceforge.net/p/jailer/discussion/700499/thread/a3635560/

2.8.1
- Fixed an incompatibility with Java 9.
Expand Down
1 change: 1 addition & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
6.3.2
- Data Browser has been improved.
- Bug fix for "Column name not exported with double quotes" https://sourceforge.net/p/jailer/discussion/700499/thread/a3635560/

6.3.1
- Fixed an incompatibility with Java 9.
Expand Down
4 changes: 2 additions & 2 deletions src/main/net/sf/jailer/DDLCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static boolean createDDL(DataModel dataModel, Session session, Temporary
}
String tableName = SQLDialect.CONFIG_TABLE_;
arguments.put("config-dml-reference", tableName);
String schema = workingTableSchema != null? new Quoting(session, true).quote(workingTableSchema) + "." : "";
String schema = workingTableSchema != null? new Quoting(session).quote(workingTableSchema) + "." : "";
arguments.put("schema", schema);
arguments.put("index-schema", supportsSchemasInIndexDefinitions(session)? schema : "");
if (tableManager != null) {
Expand Down Expand Up @@ -239,7 +239,7 @@ public static boolean isUptodate(final Session session, boolean useRowId, String
final Map<String, String> typeReplacement = Configuration.forDbms(session).getTypeReplacement();
final RowIdSupport rowIdSupport = new RowIdSupport(datamodel, Configuration.forDbms(session), useRowId);

final String schema = workingTableSchema == null ? "" : new Quoting(session, true).quote(workingTableSchema) + ".";
final String schema = workingTableSchema == null ? "" : new Quoting(session).quote(workingTableSchema) + ".";

session.executeQuery("Select jvalue from " + schema + SQLDialect.CONFIG_TABLE_ + " where jversion='" + Jailer.VERSION + "' and jkey='upk'",
new Session.ResultSetReader() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/net/sf/jailer/database/SQLDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static String dmlTableReference(String tableName, Session session) throws
if (temporaryTableScope != TemporaryTableScope.LOCAL_DATABASE) {
String schema = CommandLineParser.getInstance().workingTableSchema;
if (schema != null) {
tableRef = new Quoting(session, true).quote(schema) + "." + tableRef;
tableRef = new Quoting(session).quote(schema) + "." + tableRef;
}
}
return tableRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class JDBCMetaDataBasedModelElementFinder implements ModelElementFinder {
public Collection<Association> findAssociations(DataModel dataModel, Map<Association, String[]> namingSuggestion, Session session) throws Exception {
Collection<Association> associations = new ArrayList<Association>();
DatabaseMetaData metaData = session.getMetaData();
Quoting quoting = new Quoting(session, true);
Quoting quoting = new Quoting(session);
ResultSet resultSet;
String defaultSchema = getDefaultSchema(session, session.dbUser);

Expand Down Expand Up @@ -156,7 +156,7 @@ public Set<Table> findTables(Session session) throws Exception {

Set<Table> tables = new HashSet<Table>();
DatabaseMetaData metaData = session.getMetaData();
Quoting quoting = new Quoting(session, true);
Quoting quoting = new Quoting(session);
ResultSet resultSet;
resultSet = getTables(session, metaData, session.getIntrospectionSchema(), "%", new String[] { "TABLE" });
List<String> tableNames = new ArrayList<String>();
Expand Down Expand Up @@ -526,7 +526,7 @@ public void readCurrentRow(ResultSet resultSet) throws SQLException {
public List<Column> findColumns(Table table, Session session) throws Exception {
List<Column> columns = new ArrayList<Column>();
DatabaseMetaData metaData = session.getMetaData();
Quoting quoting = new Quoting(session, true);
Quoting quoting = new Quoting(session);
if (forDefaultSchema != session) {
forDefaultSchema = session;
_log.info("getting default schema...");
Expand Down
19 changes: 17 additions & 2 deletions src/main/net/sf/jailer/ui/databrowser/TableContentViewFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,27 @@ public Object filter(Object[] object, Map<String, Integer> name) {
bindings.put("object", object);
bindings.put("name", name);
bindings.put("df", df);
script.eval(bindings);
// script.eval(bindings);
Integer i;
i = name.get("angelegt");
if (i != null) {
object[i.intValue()] = df.format(new java.util.Date(parseInt(object[i.intValue()].toString())));
}

i = name.get("geaendert");
if (i != null) {
object[i.intValue()] = df.format(new java.util.Date(parseInt(object[i.intValue()].toString())));
}


} catch (Exception e) {
e.printStackTrace();

}
return object;
}

private long parseInt(String string) {
return Long.parseLong(string);
}

}
16 changes: 0 additions & 16 deletions src/main/net/sf/jailer/util/Quoting.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,12 @@ public class Quoting {
*/
private Set<String> keyWords = new HashSet<String>();

private final boolean force;

/**
* Constructor.
*
* @param session the database session
*/
public Quoting(Session session) throws SQLException {
this(session, false);
}

/**
* Constructor.
*
* @param session the database session
* @param force if <code>true</code>, quote unquoted identifiers
*/
public Quoting(Session session, boolean force) throws SQLException {
this.force = force;
DatabaseMetaData metaData = session.getMetaData();
String quoteString = metaData.getIdentifierQuoteString();
if (quoteString != null
Expand Down Expand Up @@ -178,9 +165,6 @@ public String quote(String identifier) {
if (identifier != null) {
identifier = identifier.trim();
}
if (!force && !isQuoted(identifier)) {
return identifier;
}
identifier = unquote(identifier);
if (quote != null && identifier != null && identifier.length() > 0) {
if (!keyWords.contains(identifier.toUpperCase())) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/net/sf/jailer/DeletionTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void testDeletion() throws Exception {

if (doDeletion(datamodelDir, new File(testDir, "extractionmodel.csv"), result, insertResult, scope)) {
Session statementExecutor = new Session(connectionArguments.get(0), connectionArguments.get(1), connectionArguments.get(2), connectionArguments.get(3));
SqlScriptExecutor.executeScript(result.getCanonicalPath(), statementExecutor);
new SqlScriptExecutor(statementExecutor, 1).executeScript(result.getCanonicalPath());
statementExecutor.shutDown();

File actualState = new File(resultDir, "remaining-state.xml");
Expand Down
2 changes: 1 addition & 1 deletion src/test/net/sf/jailer/ExportTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testExport() throws Exception {
if (format.equals("SQL")) {
DatabaseOperation.DELETE_ALL.execute(getConnection(), getDataSet());
Session statementExecutor = new Session(connectionArguments.get(0), connectionArguments.get(1), connectionArguments.get(2), connectionArguments.get(3));
SqlScriptExecutor.executeScript(result.getCanonicalPath(), statementExecutor);
new SqlScriptExecutor(statementExecutor, 1).executeScript(result.getCanonicalPath());
statementExecutor.shutDown();
assertDatabaseState(expectedResult.getCanonicalPath());
}
Expand Down
62 changes: 31 additions & 31 deletions src/test/net/sf/jailer/PseudoColumnsTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,40 @@
public class PseudoColumnsTestCase extends TestCase {

public void testPseudoColumn() throws Exception {
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A.$distance=B.$distance", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A . $distance=B . $distance", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B.$DISTANCE", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A . $DISTANCE=B . $DISTANCE", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=B", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a.$distance=b.$distance", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a . $distance=b . $distance", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b.$DISTANCE", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a . $DISTANCE=b . $DISTANCE", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=b", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A.$distance=B.$distance", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A . $distance=B . $distance", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B.$DISTANCE", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("A . $DISTANCE=B . $DISTANCE", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=B", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a.$distance=b.$distance", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a . $distance=b . $distance", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b.$DISTANCE", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=(T2.birthday - 1)", SqlUtil.resolvePseudoColumns("a . $DISTANCE=b . $DISTANCE", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1)=b", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b", "T1", "T2", 2, 1, false));

assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A.$is_subject and B.$is_subject", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A . $is_subject and B . $is_subject", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A.$IS_SUBJECT and B.$IS_SUBJECT", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A . $IS_SUBJECT and B . $IS_SUBJECT", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and B", SqlUtil.resolvePseudoColumns("A.$IS_SUBJECT and B", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a.$is_subject and b.$is_subject", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a . $is_subject and b . $is_subject", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a.$IS_SUBJECT and b.$IS_SUBJECT", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a . $IS_SUBJECT and b . $IS_SUBJECT", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and b", SqlUtil.resolvePseudoColumns("a.$IS_SUBJECT and b", "T1", "T2", 2, 1));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A.$is_subject and B.$is_subject", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A . $is_subject and B . $is_subject", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A.$IS_SUBJECT and B.$IS_SUBJECT", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("A . $IS_SUBJECT and B . $IS_SUBJECT", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and B", SqlUtil.resolvePseudoColumns("A.$IS_SUBJECT and B", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a.$is_subject and b.$is_subject", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a . $is_subject and b . $is_subject", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a.$IS_SUBJECT and b.$IS_SUBJECT", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and (T2.birthday - 1 = 0)", SqlUtil.resolvePseudoColumns("a . $IS_SUBJECT and b . $IS_SUBJECT", "T1", "T2", 2, 1, false));
assertEquals("(T1.birthday - 1 = 0) and b", SqlUtil.resolvePseudoColumns("a.$IS_SUBJECT and b", "T1", "T2", 2, 1, false));

assertEquals("(1 = 0)", SqlUtil.resolvePseudoColumns("b . $IS_SUBJECT", "T1", null, 2, 1));
assertEquals("(1 = 0)", SqlUtil.resolvePseudoColumns("b . $IS_SUBJECT", "T1", null, 2, 1, false));

assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A.$distance=B.$distance", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A . $distance=B . $distance", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B.$DISTANCE", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A . $DISTANCE=B . $DISTANCE", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=B", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a.$distance=b.$distance", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a . $distance=b . $distance", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b.$DISTANCE", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a . $DISTANCE=b . $DISTANCE", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=b", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b", "T1", null, 3, 1));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A.$distance=B.$distance", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A . $distance=B . $distance", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B.$DISTANCE", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("A . $DISTANCE=B . $DISTANCE", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=B", SqlUtil.resolvePseudoColumns("A.$DISTANCE=B", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a.$distance=b.$distance", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a . $distance=b . $distance", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b.$DISTANCE", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=2", SqlUtil.resolvePseudoColumns("a . $DISTANCE=b . $DISTANCE", "T1", null, 3, 1, false));
assertEquals("(T1.birthday - 1)=b", SqlUtil.resolvePseudoColumns("a.$DISTANCE=b", "T1", null, 3, 1, false));
}

}

0 comments on commit e8e956f

Please sign in to comment.