Revision: 4070
Author:
ki...@sqlpower.ca
Date: Fri May 1 20:46:13 2015 UTC
Log: Revision for comparing Data Models using Postgres Database.
Related to Bug 3164.
https://code.google.com/p/power-architect/source/detail?r=4070
Modified:
/trunk/src/main/java/ca/sqlpower/architect/ddl/DDLGenerator.java
/trunk/src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/CompareDMFormatter.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ddl/DDLGenerator.java Tue
Mar 31 21:03:24 2015 UTC
+++ /trunk/src/main/java/ca/sqlpower/architect/ddl/DDLGenerator.java Fri
May 1 20:46:13 2015 UTC
@@ -361,5 +361,12 @@
*
*/
public String getPhysicalName(SQLObject object);
+
+ /**
+ *
+ * set to 'true' if comparing Data Model for Postgres database.
+ * @param isComparingDMForPostgres
+ */
+ public void setComparingDMForPostgres(boolean
isComparingDMForPostgres);
}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
Thu Apr 23 20:11:31 2015 UTC
+++ /trunk/src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
Fri May 1 20:46:13 2015 UTC
@@ -157,6 +157,12 @@
*/
protected Map<String, ProfileFunctionDescriptor> profileFunctionMap;
+ /**
+ * used to quote the physical name.
+ * default value is 'false'. set to 'true' only when comparing Data
Model for Postgres Database.
+ */
+ protected boolean isComparingDMForPostgres = false;
+
private ArchitectSwingSession session;
public GenericDDLGenerator(boolean allowConnection) throws
SQLException {
@@ -1457,17 +1463,20 @@
* @return name with quotes, if database supports quoting name
*/
public String getQuotedPhysicalName(String name) {
+ if (name == null) return null;
+ boolean isQuoting = false;
if (session != null && session.getDDLGenerator() != null &&
session.getDDLGenerator().getClass().getName().equals(PostgresDDLGenerator.class.getName()))
{
DataSourceCollection<JDBCDataSource> dataSourceCollection=
session.getDataSources();
for (JDBCDataSourceType dsType :
dataSourceCollection.getDataSourceTypes()) {
if
(dsType.getDDLGeneratorClass().equals(PostgresDDLGenerator.class.getName()))
{
- boolean isQuoting = dsType.getSupportsQuotingName();
- if (isQuoting && (!((name.startsWith("\"")) &&
name.endsWith("\"")))) {
- name = "\""+name+"\"";
- }
+ isQuoting = dsType.getSupportsQuotingName();
break;
}
}
+ }
+ if ((isQuoting || isComparingDMForPostgres())
+ && !(name.startsWith("\"") && name.endsWith("\""))) {
+ name = "\""+name+"\"";
}
return name;
}
@@ -1480,4 +1489,16 @@
return name;
}
+ @Override
+ public void setComparingDMForPostgres(boolean
isComparingDMForPostgres) {
+ this.isComparingDMForPostgres = isComparingDMForPostgres;
+ }
+
+ /**
+ * @return the isComparingDMForPostgres
+ */
+ public boolean isComparingDMForPostgres() {
+ return isComparingDMForPostgres;
+ }
+
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/CompareDMFormatter.java
Thu Apr 23 20:11:31 2015 UTC
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/CompareDMFormatter.java
Fri May 1 20:46:13 2015 UTC
@@ -39,6 +39,7 @@
import ca.sqlpower.architect.ddl.DDLGenerator;
import ca.sqlpower.architect.ddl.LiquibaseDDLGenerator;
+import ca.sqlpower.architect.ddl.PostgresDDLGenerator;
import ca.sqlpower.architect.diff.ArchitectDiffException;
import ca.sqlpower.architect.swingui.CompareDMPanel.SourceOrTargetStuff;
import
ca.sqlpower.architect.swingui.CompareDMSettings.SourceOrTargetSettings;
@@ -158,6 +159,10 @@
if
(dmSetting.getOutputFormat().equals(CompareDMSettings.OutputFormat.SQL)) {
gen = dmSetting.getDdlGenerator().newInstance();
+ if (gen instanceof PostgresDDLGenerator) {
+ //setComparingDMForPostgres 'true' to quote the
physical name
+ gen.setComparingDMForPostgres(true);
+ }
SQLCatalog cat = (SQLCatalog)
dmSetting.getSourceSettings().getCatalogObject();
SQLSchema sch = (SQLSchema)
dmSetting.getSourceSettings().getSchemaObject();
gen.setTargetCatalog(cat == null ? null :
gen.getPhysicalName(cat));