package com.quantum.adapters;
-import com.quantum.sql.SQLHelper;
+import java.util.HashMap;
+import java.util.Map;
+
import com.quantum.util.QuantumUtil;
import com.quantum.util.sql.TypesHelper;
public class PostgresAdapter extends DatabaseAdapter {
- public String getShowTableQuery(String qualifier, boolean isDefault) {
+ protected PostgresAdapter() {
+ super(AdapterFactory.POSTGRES);
+ }
+ public String getShowTableQuery(String qualifier) {
return "SELECT SCHEMANAME, TABLENAME FROM PG_TABLES WHERE SCHEMANAME = '"
+ qualifier + "'";
}
- public String getShowViewQuery(String qualifier, boolean isDefault) {
+ public String getShowViewQuery(String qualifier) {
return "SELECT SCHEMANAME, VIEWNAME FROM PG_VIEWS WHERE SCHEMANAME = '"
+ qualifier + "'";
}
- public String getShowSequenceQuery(String qualifier, boolean isDefault) {
- return "SELECT SCHEMANAME, relname FROM pg_class WHERE relkind = 'S'" +
- "AND SCHEMANAME = '" + qualifier + "'";
+ public String getShowSequenceQuery(String qualifier) {
+ return "select pg_namespace.nspname, relname " +
+ "from pg_class, pg_namespace where relkind = 'S' " +
+ "and relnamespace = pg_namespace.oid " +
+ "and pg_namespace.nspname = '" + qualifier + "'";
}
public String getNextValue(String sequence, String owner) {
- return "SELECT NEXTVAL('" + SQLHelper.getQualifiedName(owner, sequence) + "')";
+ return "SELECT NEXTVAL('" + getQualifiedName(owner, sequence) + "')";
}
public String getPrevValue(String sequence, String owner) {
- return "SELECT * FROM " + SQLHelper.getQualifiedName(owner, sequence);
+ return "SELECT * FROM " + getQualifiedName(owner, sequence);
}
/**
return super.quote(string, type, typeString);
}
+ public String getTableQuery(String table) {
+ return "SELECT OID, * FROM " + filterTableName(table); //$NON-NLS-1$
+ }
/**
* @see com.quantum.adapters.DatabaseAdapter#filterTableName(java.lang.String)
*/
return "public";
}
+ public Map getDefaultConnectionParameters() {
+ Map map = new HashMap();
+ map.put("port", "5432");
+ map.put("hostname", "localhost");
+ return map;
+ }
}
\ No newline at end of file