提交 e8b0902f 编写于 作者: J jurgen

DB2 FQ names fix.

DB2 tables cache fix.
上级 0fd996e8
......@@ -30,7 +30,7 @@ import java.util.Collection;
*/
public interface DBSProcedure extends DBSObject, DBPQualifiedObject
{
DBSObjectContainer getContainer();
DBSObject getContainer();
DBSProcedureType getProcedureType();
......
......@@ -27,6 +27,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.edit.DBEPersistAction;
import org.jkiss.dbeaver.ext.db2.model.DB2DataSource;
import org.jkiss.dbeaver.ext.db2.model.DB2Schema;
......@@ -80,9 +81,8 @@ public class DB2SchemaManager extends SQLObjectEditor<DB2Schema, DB2DataSource>
@Override
protected DBEPersistAction[] makeObjectCreateActions(ObjectCreateCommand command)
{
String schemaName = command.getObject().getName();
SQLDatabasePersistAction action = new SQLDatabasePersistAction("Create schema", String.format(SQL_CREATE_SCHEMA,
schemaName));
DBUtils.getQuotedIdentifier(command.getObject())));
return new DBEPersistAction[] { action };
}
......@@ -91,7 +91,7 @@ public class DB2SchemaManager extends SQLObjectEditor<DB2Schema, DB2DataSource>
{
String schemaName = command.getObject().getName();
DBEPersistAction action = new SQLDatabasePersistAction("Drop schema (SQL)", String.format(SQL_DROP_SCHEMA,
schemaName));
DBUtils.getQuotedIdentifier(command.getObject())));
return new DBEPersistAction[] { action };
}
......
......@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.ext.db2.model.dict.DB2RoutineValidType;
import org.jkiss.dbeaver.ext.db2.model.dict.DB2YesNo;
import org.jkiss.dbeaver.ext.db2.model.module.DB2Module;
import org.jkiss.dbeaver.model.DBPRefreshableObject;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.meta.Property;
......@@ -175,13 +176,18 @@ public class DB2Routine extends DB2Object<DBSObject> implements DBSProcedure, DB
@Override
public String getFullQualifiedName()
{
return parent.getName() + "." + name;
return DBUtils.getFullQualifiedName(getDataSource(),
parent,
this);
}
@Override
public DBSObjectContainer getContainer()
{
return getContainer();
if (parent instanceof DBSObjectContainer) {
return (DBSObjectContainer) parent;
}
return db2Schema;
}
@Override
......
......@@ -52,9 +52,7 @@ import org.jkiss.utils.CommonUtils;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
import java.util.*;
/**
* DB2Schema
......@@ -96,9 +94,6 @@ public class DB2Schema extends DB2GlobalObject implements DBSSchema, DBPRefresha
private final DB2TableReferenceCache referenceCache = new DB2TableReferenceCache(tableCache);
private final DB2TableCheckConstraintCache checkCache = new DB2TableCheckConstraintCache(tableCache);
// Combined Cache for the content assist to work. Aliases being not DB2TableBase, they are alas not included...
private Map<String, DB2TableBase> allKindOfTableCache;
private String name;
private String owner;
private DB2OwnerType ownerType;
......@@ -268,34 +263,28 @@ public class DB2Schema extends DB2GlobalObject implements DBSSchema, DBPRefresha
@Override
public Collection<DB2TableBase> getChildren(DBRProgressMonitor monitor) throws DBException
{
// Build only once, a combined cache of ""Tables"" for content assist to work
if (allKindOfTableCache == null) {
allKindOfTableCache = new TreeMap<String, DB2TableBase>(); // TreeMap to keep things ordered
for (DB2Table db2Table : tableCache.getObjects(monitor, this)) {
allKindOfTableCache.put(db2Table.getName(), db2Table);
}
for (DB2View db2View : viewCache.getObjects(monitor, this)) {
allKindOfTableCache.put(db2View.getName(), db2View);
}
for (DB2MaterializedQueryTable db2Mqt : mqtCache.getObjects(monitor, this)) {
allKindOfTableCache.put(db2Mqt.getName(), db2Mqt);
}
for (DB2Nickname db2Nickname : nicknameCache.getObjects(monitor, this)) {
allKindOfTableCache.put(db2Nickname.getName(), db2Nickname);
}
}
return allKindOfTableCache.values();
List<DB2TableBase> allChildren = new ArrayList<DB2TableBase>();
allChildren.addAll(tableCache.getObjects(monitor, this));
allChildren.addAll(viewCache.getObjects(monitor, this));
allChildren.addAll(mqtCache.getObjects(monitor, this));
allChildren.addAll(nicknameCache.getObjects(monitor, this));
return allChildren;
}
@Override
public DB2TableBase getChild(DBRProgressMonitor monitor, String childName) throws DBException
{
if (allKindOfTableCache == null) {
getChildren(monitor);
DB2TableBase child = tableCache.getObject(monitor, this, childName);
if (child == null) {
child = viewCache.getObject(monitor, this, childName);
}
if (child == null) {
child = mqtCache.getObject(monitor, this, childName);
}
if (child == null) {
child = nicknameCache.getObject(monitor, this, childName);
}
return allKindOfTableCache.get(childName);
return child;
}
// -----------------
......
......@@ -25,6 +25,7 @@ import org.jkiss.dbeaver.ext.db2.editors.DB2StatefulObject;
import org.jkiss.dbeaver.ext.db2.model.dict.DB2OwnerType;
import org.jkiss.dbeaver.model.DBPNamedObject2;
import org.jkiss.dbeaver.model.DBPRefreshableObject;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
......@@ -100,7 +101,9 @@ public abstract class DB2TableBase extends JDBCTable<DB2DataSource, DB2Schema> i
@Override
public String getFullQualifiedName()
{
return getContainer().getName() + "." + this.getName();
return DBUtils.getFullQualifiedName(getDataSource(),
getContainer(),
this);
}
// -----------------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册