Java Code Examples for net.sf.jsqlparser.schema.Table#setName()

The following examples show how to use net.sf.jsqlparser.schema.Table#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSQLParserAdapter.java    From ddal with Apache License 2.0 6 votes vote down vote up
private void routeTable(TableWrapper tab, Column column, Object sdValue) {
    if (tab == null) {//
        return;
    }
    if (tab == AMBIGUOUS_TABLE) {
        throw new RuntimeException("Shard value '" + column.toString() + "' in where clause is ambiguous. Sql is ["
                                   + sql + "]");
    }
    ShardRouteInfo routeInfo = getRouteInfo(tab, sdValue);
    // 当没有设置别名,但分表字段使用了表前缀时,别前缀需要根据路由结果进行重写;
    // 这里之所有没有采用将table取名的方式是因为update/delete/insert不全支持别名;
    // 由于select都是支持别名的,所有都会被添加别名,因此不会执行下面的操作;
    Table columnTable = column.getTable();
    if (tab.getAlias() == null && columnTable != null && columnTable.getName() != null
        && columnTable.getName().length() > 0) {
        if (columnTable.getSchemaName() != null) {
            columnTable.setSchemaName(routeInfo.getScName());
        }
        columnTable.setName(routeInfo.getTbName());
    }
    route0(tab, routeInfo);
}
 
Example 2
Source File: SqlSecurerVisitor.java    From evosql with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(Table arg0) {
	if (arg0.getName() == null) return;
	
	arg0.setName(secureName(arg0.getName()));
	
	// Handle alias
	if (arg0.getAlias() != null) {
		arg0.getAlias().setName(secureName(arg0.getAlias().getName()));
	}
}
 
Example 3
Source File: CryptoVisitor.java    From evosql with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(Table arg0) {
	if (arg0.getName() == null) return;
	
	arg0.setName(transform(arg0.getName()));
	
	// Handle alias
	if (arg0.getAlias() != null) {
		arg0.getAlias().setName(transform(arg0.getAlias().getName()));
	}
}
 
Example 4
Source File: TableRenameVisitor.java    From compass with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(Table table) 
{
    String fullyQualifiedName = table.getFullyQualifiedName();
    if (!otherItemNames.contains(fullyQualifiedName.toLowerCase()))
    {
        String oldTableName=table.getName();
        String newTableName=this.tableRenamer.rename(oldTableName);
        table.setName(newTableName);
    }
}
 
Example 5
Source File: SelectSqlConverter.java    From mybatis-shard with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void visit(Table tableName) {
    String tableNameName = tableName.getName();

    if (includePattern.matcher(tableNameName).find()) {

        String newName = convertTableName(tableNameName, suffix);
        tableName.setName(newName);
    }
}
 
Example 6
Source File: ElasticSearchSqlServiceImpl.java    From elasticsearch-sql with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(Table tableName) {
    tableName.setName(tableName.getName());
}