1. tbrugz
  2. sqldump

Commits

tbrugz  committed d29a1e6

sqldump/model: fixed quoting in comments

  • Participants
  • Parent commits d5cfdb6
  • Branches default

Comments (0)

Files changed (4)

File src/tbrugz/sqldump/SchemaModelScriptDumper.java

View file
  • Ignore whitespace
 			}
 			
 			categorizedOut(table.getSchemaName(), table.getName(), DBObjectType.TABLE, table.getDefinition(dumpWithSchemaName, doSchemaDumpPKs, dumpFKsInsideTable, dumpDropStatements, colTypeConversionProp, schemaModel.getForeignKeys())+";\n");
-			String afterTableScript = table.getAfterCreateTableScript();
+			String afterTableScript = table.getAfterCreateTableScript(dumpWithSchemaName);
 			if(afterTableScript!=null && !afterTableScript.trim().equals("")) {
 				categorizedOut(table.getSchemaName(), table.getName(), DBObjectType.TABLE, afterTableScript);
 			}

File src/tbrugz/sqldump/dbmodel/DBObject.java

View file
  • Ignore whitespace
 		return sqlIddecorator.get(id);
 	}
 	
-	/*private static String getFinalQualifiedName(NamedDBObject dbobject, boolean dumpSchemaName) {
+	static String getFinalQualifiedName(NamedDBObject dbobject, boolean dumpSchemaName) {
 		return ((dumpSchemaName && dbobject.getSchemaName()!=null)?
 				sqlIddecorator.get(dbobject.getSchemaName())+".":"")+sqlIddecorator.get(dbobject.getName());
-	}*/
+	}
 
 	public static String getFinalQualifiedName(String schemaName, String name, boolean dumpSchemaName) {
 		return ((dumpSchemaName && schemaName!=null)?

File src/tbrugz/sqldump/dbmodel/Table.java

View file
  • Ignore whitespace
 		return "";
 	}
 	
-	public String getAfterCreateTableScript() {
+	public String getAfterCreateTableScript(boolean dumpSchemaName) {
 		//e.g.: COMMENT ON COLUMN [schema.]table.column IS 'text'
 		StringBuffer sb = new StringBuffer();
-		String stmp = getRelationRemarks(this);
+		String stmp = getRelationRemarks(this, dumpSchemaName);
 		if(stmp!=null && stmp.length()>0) { sb.append(stmp+";\n"); }
 
-		stmp = getColumnRemarks(columns, this);
+		stmp = getColumnRemarks(columns, this, dumpSchemaName);
 		if(stmp!=null && stmp.length()>0) { sb.append(stmp+";\n"); }
 
 		return sb.toString();
 		return ret;
 	}
 	
-	static String getRelationRemarks(Relation rel) {
+	static String getRelationRemarks(Relation rel, boolean dumpSchemaName) {
 		StringBuffer sb = new StringBuffer();
 		String tableComment = rel.getRemarks();
 		if(tableComment!=null && !tableComment.trim().equals("")) {
 			tableComment = tableComment.replaceAll("'", "''");
-			sb.append("comment on table "+rel.getSchemaName()+"."+rel.getName()+" is '"+tableComment+"'"); //;\n
+			sb.append("comment on table "+DBObject.getFinalQualifiedName(rel, dumpSchemaName)+" is '"+tableComment+"'"); //;\n
 		}
 		return sb.toString();
 	}
 	
-	static String getColumnRemarks(List<Column> columns, Relation rel) {
+	static String getColumnRemarks(List<Column> columns, Relation rel, boolean dumpSchemaName) {
 		StringBuffer sb = new StringBuffer();
 		//XXX: column comments should be ordered by col name?
 		int commentCount = 0;
 					//XXXdone: escape comment
 					comment = comment.replaceAll("'", "''");
 					if(commentCount>0) { sb.append(";\n"); }
-					sb.append("comment on column "+rel.getSchemaName()+"."+rel.getName()+"."+c.name+" is '"+comment+"'");
+					sb.append("comment on column "+DBObject.getFinalQualifiedName(rel, dumpSchemaName)+"."+DBObject.getFinalIdentifier(c.name)+" is '"+comment+"'");
 					commentCount++;
 				}
 			}

File src/tbrugz/sqldump/dbmodel/View.java

View file
  • Ignore whitespace
 
 		StringBuffer sbRemarks = new StringBuffer();
 
-		String stmp1 = Table.getRelationRemarks(this);
-		String stmp2 = Table.getColumnRemarks(columns, this);
+		String stmp1 = Table.getRelationRemarks(this, dumpSchemaName);
+		String stmp2 = Table.getColumnRemarks(columns, this, dumpSchemaName);
 		
 		if(stmp1!=null && stmp1.length()>0 && stmp2!=null && stmp2.length()>0) { sbRemarks.append("\n\n"); }
 		if(stmp1!=null && stmp1.length()>0) { sbRemarks.append(stmp1+";\n"); }