final String userName; qualifiedTable.setName(table.getName()); qualifiedTable.setAlias(table.getAlias());
/** * Add new entries to the table name map. * * @param originalName a table name that should be replaced * @param newName the value that originalName should be replaced with */ public void put(String originalName, String newName) { Table t = new Table(); String[] parts = newName.split("[.]"); if (parts.length == 1) { t.setName(parts[0]); } else if (parts.length == 2) { t.setSchemaName(parts[0]); t.setName(parts[1]); } else if (parts.length == 3) { t.setSchemaName(parts[0] + "." + parts[1]); t.setName(parts[2]); } else throw new IllegalArgumentException("expected new table name to have 1-3 parts, found " + parts.length); map.put(originalName, t); }
/** * Add new entries to the table name map. * * @param originalName a table name that should be replaced * @param newName the value that originalName should be replaced with */ public void put(String originalName, String newName) { Table t = new Table(); String[] parts = newName.split("[.]"); if (parts.length == 1) { t.setName(parts[0]); } else if (parts.length == 2) { t.setSchemaName(parts[0]); t.setName(parts[1]); } else if (parts.length == 3) { t.setSchemaName(parts[0] + "." + parts[1]); t.setName(parts[2]); } else throw new IllegalArgumentException("expected new table name to have 1-3 parts, found " + parts.length); map.put(originalName, t); }
@Override public void visit(AllTableColumns allTableColumns) { Table table = allTableColumns.getTable(); if (table != null) { String name = table.getName(); if (name != null) { table.setName(name.toLowerCase()); } } }
@Override public void visit(Table table) { log.debug("visit(table)" + table); String tabName = table.getWholeTableName(); log.debug("looking for " + tabName + " in conversion map..."); Table ntab = map.get(tabName); log.debug("found: " + ntab); if (ntab != null) { log.debug("convert: " + table.getSchemaName() + "." + table.getName() + " -> " + ntab.getSchemaName() + "." + ntab.getName()); table.setName(ntab.getName()); table.setSchemaName(ntab.getSchemaName()); // leave alias intact } } }
@Override public void visit(Table tableName) { if (tableName == null) { return; } String name = tableName.getName(); if (name != null) { tableName.setName(CompatibilityUtils.fixMySqlName(name.toLowerCase())); } Alias alias = tableName.getAlias(); if (alias != null) { String aliasName = alias.getName(); if (aliasName != null) { alias.setName(CompatibilityUtils.fixMySqlName(aliasName.toLowerCase())); } } }
@Override public void visit(Column column) { log.debug("visit(column)" + column); Table table = column.getTable(); log.debug("table: " + table); if (table != null && table.getName() != null) { String tabName = table.getWholeTableName(); log.debug("looking for " + tabName + " in conversion map..."); Table ntab = map.get(tabName); log.debug("found: " + ntab); if (ntab != null) { log.debug("convert: " + table.getSchemaName() + "." + table.getName() + " -> " + ntab.getSchemaName() + "." + ntab.getName()); table.setName(ntab.getName()); table.setSchemaName(ntab.getSchemaName()); // leave alias intact } } } }
@Override public void visit(Column column) { net.sf.jsqlparser.schema.Table table = column.getTable(); if (table == null) { table = new net.sf.jsqlparser.schema.Table(mainAlias); column.setTable(table); } else { if (StringUtils.isBlank(table.getName())) { table.setName(mainAlias); } } } });
final String userName; qualifiedTable.setName(table.getName()); qualifiedTable.setAlias(table.getAlias());
public static void normalizeColumnName(QuotedIDFactory idfac, Column tableColumn) { QuotedID columnName = idfac.createAttributeID(tableColumn.getColumnName()); tableColumn.setColumnName(columnName.getSQLRendering()); Table table = tableColumn.getTable(); RelationID tableName = idfac.createRelationID(table.getSchemaName(), table.getName()); table.setSchemaName(tableName.getSchemaSQLRendering()); table.setName(tableName.getTableNameSQLRendering()); }