Skip to content

Commit

Permalink
0001466: REST API - setting the target schema and/or catalog does not…
Browse files Browse the repository at this point in the history
… work when using the REST API

0001465: REST API - default schema and/or catalog are filled in for generated sql statement even if they are blank in sym_trigger
  • Loading branch information
chenson42 committed Nov 16, 2013
1 parent 23479ee commit 5e9184f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
22 changes: 22 additions & 0 deletions symmetric-db/src/main/java/org/jumpmind/db/model/Table.java
Expand Up @@ -40,6 +40,10 @@ public class Table implements Serializable, Cloneable {

/** Unique ID for serialization purposes. */
private static final long serialVersionUID = -5541154961302342608L;

private String oldCatalog = null;

private String oldSchema = null;

/** The catalog of this table as read from the database. */
private String catalog = null;
Expand Down Expand Up @@ -129,6 +133,7 @@ public String getCatalog() {
* The catalog
*/
public void setCatalog(String catalog) {
this.oldCatalog = this.catalog != null ? this.catalog : catalog;
this.catalog = catalog;
}

Expand All @@ -148,6 +153,7 @@ public String getSchema() {
* The schema
*/
public void setSchema(String schema) {
this.oldSchema = this.schema != null ? this.schema : schema;
this.schema = schema;
}

Expand Down Expand Up @@ -1084,6 +1090,22 @@ public static Column[] orderColumns(String[] columnNames, Table table) {
}
return orderedColumns;
}

public String getOldCatalog() {
return oldCatalog;
}

public void setOldCatalog(String oldCatalog) {
this.oldCatalog = oldCatalog;
}

public String getOldSchema() {
return oldSchema;
}

public void setOldSchema(String oldSchema) {
this.oldSchema = oldSchema;
}

public Table copy() {
try {
Expand Down
Expand Up @@ -103,9 +103,21 @@ public void start(Batch batch) {
}

public boolean start(Table table) {
this.currentTable = platform.getTableFromCache(table.getCatalog(), table.getSchema(), table.getName(), false);
/*
* in the case when the target schema or catalog is set then we need to
* use the previous schema or catalog to look up the table locally.
*/
this.currentTable = platform.getTableFromCache(table.getOldCatalog(), table.getOldSchema(), table.getName(), false);
this.currentTable = currentTable.copyAndFilterColumns(table.getColumnNames(),
table.getPrimaryKeyColumnNames(), true);
table.getPrimaryKeyColumnNames(), true);
/*
* restore the schema and catalog from the passed in table because they
* might have not been set, but get set to the default after the table
* is looked up locally
*/
this.currentTable.setSchema(table.getSchema());
this.currentTable.setCatalog(table.getCatalog());
this.currentTable.setName(table.getName());
return true;
}

Expand Down

0 comments on commit 5e9184f

Please sign in to comment.