diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-11-10 03:48:45 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-11-10 03:48:45 +0000 |
commit | b07155fe474af94ea16a1677b1fc22a84002738c (patch) | |
tree | 8d6ebab8441c5b02f2dddd3800440d7b81d3e52f /src | |
parent | b0e9d0a4dca4262b92de7532513c3a38b3007b1e (diff) | |
download | jackcess-b07155fe474af94ea16a1677b1fc22a84002738c.tar.gz jackcess-b07155fe474af94ea16a1677b1fc22a84002738c.zip |
quote remotedb, add support for remotedb type
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@388 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
6 files changed, 55 insertions, 22 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/query/AppendQuery.java b/src/java/com/healthmarketscience/jackcess/query/AppendQuery.java index 38842e1..ef4d1a1 100644 --- a/src/java/com/healthmarketscience/jackcess/query/AppendQuery.java +++ b/src/java/com/healthmarketscience/jackcess/query/AppendQuery.java @@ -46,10 +46,14 @@ public class AppendQuery extends BaseSelectQuery return getTypeRow().name1; } - public String getRemoteDb() { + public String getRemoteDbPath() { return getTypeRow().name2; } + public String getRemoteDbType() { + return getTypeRow().expression; + } + protected List<Row> getValueRows() { return filterRowsByFlag(super.getColumnRows(), APPEND_VALUE_FLAG); } @@ -71,11 +75,11 @@ public class AppendQuery extends BaseSelectQuery protected void toSQLString(StringBuilder builder) { builder.append("INSERT INTO ").append(getTargetTable()); - toRemoteDb(builder, getRemoteDb()); + toRemoteDb(builder, getRemoteDbPath(), getRemoteDbType()); builder.append(NEWLINE); List<String> values = getValues(); if(!values.isEmpty()) { - builder.append("VALUES (").append(values).append(")"); + builder.append("VALUES (").append(values).append(')'); } else { toSQLSelectString(builder, true); } diff --git a/src/java/com/healthmarketscience/jackcess/query/BaseSelectQuery.java b/src/java/com/healthmarketscience/jackcess/query/BaseSelectQuery.java index 24a6f96..30cbd5d 100644 --- a/src/java/com/healthmarketscience/jackcess/query/BaseSelectQuery.java +++ b/src/java/com/healthmarketscience/jackcess/query/BaseSelectQuery.java @@ -52,7 +52,7 @@ public abstract class BaseSelectQuery extends Query builder.append("SELECT "); String selectType = getSelectType(); if(!DEFAULT_TYPE.equals(selectType)) { - builder.append(selectType).append(" "); + builder.append(selectType).append(' '); } } @@ -62,7 +62,7 @@ public abstract class BaseSelectQuery extends Query List<String> fromTables = getFromTables(); if(!fromTables.isEmpty()) { builder.append(NEWLINE).append("FROM ").append(fromTables); - toRemoteDb(builder, getFromRemoteDb()); + toRemoteDb(builder, getFromRemoteDbPath(), getFromRemoteDbType()); } String whereExpr = getWhereExpression(); @@ -135,9 +135,15 @@ public abstract class BaseSelectQuery extends Query } @Override - public String getFromRemoteDb() + public String getFromRemoteDbPath() { - return super.getFromRemoteDb(); + return super.getFromRemoteDbPath(); + } + + @Override + public String getFromRemoteDbType() + { + return super.getFromRemoteDbType(); } @Override diff --git a/src/java/com/healthmarketscience/jackcess/query/MakeTableQuery.java b/src/java/com/healthmarketscience/jackcess/query/MakeTableQuery.java index 4d62bba..c7dbc4b 100644 --- a/src/java/com/healthmarketscience/jackcess/query/MakeTableQuery.java +++ b/src/java/com/healthmarketscience/jackcess/query/MakeTableQuery.java @@ -46,15 +46,19 @@ public class MakeTableQuery extends BaseSelectQuery return getTypeRow().name1; } - public String getRemoteDb() { + public String getRemoteDbPath() { return getTypeRow().name2; } + public String getRemoteDbType() { + return getTypeRow().expression; + } + @Override protected void toSelectInto(StringBuilder builder) { builder.append(" INTO ").append(getTargetTable()); - toRemoteDb(builder, getRemoteDb()); + toRemoteDb(builder, getRemoteDbPath(), getRemoteDbType()); } @Override diff --git a/src/java/com/healthmarketscience/jackcess/query/Query.java b/src/java/com/healthmarketscience/jackcess/query/Query.java index 7a78d79..5ad8dbc 100644 --- a/src/java/com/healthmarketscience/jackcess/query/Query.java +++ b/src/java/com/healthmarketscience/jackcess/query/Query.java @@ -181,7 +181,7 @@ public abstract class Query List<String> params = getParameters(); if(!params.isEmpty()) { builder.append("PARAMETERS ").append(params) - .append(";").append(NEWLINE); + .append(';').append(NEWLINE); } } @@ -195,9 +195,9 @@ public abstract class Query throw new IllegalStateException("Unknown param type " + row.flag); } - builder.append(name).append(" ").append(typeName); + builder.append(name).append(' ').append(typeName); if((TEXT_FLAG.equals(row.flag)) && (getIntValue(row.extra, 0) > 0)) { - builder.append("(").append(row.extra).append(")"); + builder.append('(').append(row.extra).append(')'); } } }).format(); @@ -266,11 +266,16 @@ public abstract class Query throw new IllegalStateException("Cannot find join table " + table); } - protected String getFromRemoteDb() + protected String getFromRemoteDbPath() { return getRemoteDatabaseRow().name1; } + protected String getFromRemoteDbType() + { + return getRemoteDatabaseRow().expression; + } + protected String getWhereExpression() { return getWhereRow().expression; @@ -318,7 +323,7 @@ public abstract class Query builder.append(NEWLINE).append(accessType); } - builder.append(";"); + builder.append(';'); } return builder.toString(); } @@ -446,13 +451,22 @@ public abstract class Query protected static StringBuilder toQuotedExpr(StringBuilder builder, String expr) { - return builder.append("[").append(expr).append("]"); + return builder.append('[').append(expr).append(']'); } protected static StringBuilder toRemoteDb(StringBuilder builder, - String remoteDb) { - if(remoteDb != null) { - builder.append(" IN ").append(remoteDb); + String remoteDbPath, + String remoteDbType) { + if((remoteDbPath != null) || (remoteDbType != null)) { + // note, always include path string, even if empty + builder.append(" IN '"); + if(remoteDbPath != null) { + builder.append(remoteDbPath); + } + builder.append('\''); + if(remoteDbType != null) { + builder.append(" [").append(remoteDbType).append(']'); + } } return builder; } diff --git a/src/java/com/healthmarketscience/jackcess/query/UnionQuery.java b/src/java/com/healthmarketscience/jackcess/query/UnionQuery.java index e323b83..05f0c51 100644 --- a/src/java/com/healthmarketscience/jackcess/query/UnionQuery.java +++ b/src/java/com/healthmarketscience/jackcess/query/UnionQuery.java @@ -77,7 +77,7 @@ public class UnionQuery extends Query .append("UNION "); String unionType = getUnionType(); if(!DEFAULT_TYPE.equals(unionType)) { - builder.append(unionType).append(" "); + builder.append(unionType).append(' '); } builder.append(getUnionString2()); List<String> orderings = getOrderings(); diff --git a/src/java/com/healthmarketscience/jackcess/query/UpdateQuery.java b/src/java/com/healthmarketscience/jackcess/query/UpdateQuery.java index 30c7769..b94d5ce 100644 --- a/src/java/com/healthmarketscience/jackcess/query/UpdateQuery.java +++ b/src/java/com/healthmarketscience/jackcess/query/UpdateQuery.java @@ -47,9 +47,14 @@ public class UpdateQuery extends Query return super.getFromTables(); } - public String getRemoteDb() + public String getRemoteDbPath() { - return super.getFromRemoteDb(); + return super.getFromRemoteDbPath(); + } + + public String getRemoteDbType() + { + return super.getFromRemoteDbType(); } public List<String> getNewValues() @@ -72,7 +77,7 @@ public class UpdateQuery extends Query protected void toSQLString(StringBuilder builder) { builder.append("UPDATE ").append(getTargetTables()); - toRemoteDb(builder, getRemoteDb()); + toRemoteDb(builder, getRemoteDbPath(), getRemoteDbType()); builder.append(NEWLINE).append("SET ").append(getNewValues()); |