Closed
Description
Always check against the Latest SNAPSHOT of JSQLParser and the Syntax Diagram
Failing JAVA Feature:
static class TableNamePrefixVisitor extends TablesNamesFinder {
static final List<String> IGNORE_SCHEMAS = Arrays.asList("mysql", "information_schema", "performance_schema");
private final String prefix;
public TableNamePrefixVisitor(String prefix) {
this.prefix = prefix;
}
@Override
public void visit(Table tableName) {
String schemaName = tableName.getSchemaName();
if (schemaName != null && IGNORE_SCHEMAS.contains(schemaName.toLowerCase())) {
return;
}
String originTableName = tableName.getName();
tableName.setName(prefix + originTableName);
if (originTableName.startsWith("`")) {
tableName.setName("`" + prefix + originTableName.replace("`", "") + "`");
}
-
in main
String sql="UPDATE table_1 a SET a.a1 = (SELECT b1 FROM table_2 b WHERE b.xx = 'xx'), a.a2 = (SELECT b2 FROM table_2 b WHERE b.yy='yy')"; Statement statement = CCJSqlParserUtil.parse(sql); TableNamePrefixVisitor tableNamePrefixVisitor = new TableNamePrefixVisitor("test_"); statement.accept(tableNamePrefixVisitor);
-result
UPDATE test_table_1 a SET a.a1 = (SELECT b1 FROM test_table_2 b WHERE b.xx = 'xx'), a.a2 = (SELECT b2 FROM table_2 b WHERE b.yy = 'yy')
-problem
SELECT b2 FROM table_2 b WHERE b.yy='yy', in this select sql ,table_2 is not added prefix Test_.
SQL Example:
- Simplified Query Example, focusing on the failing feature
UPDATE table_1 a SET a.a1 = (SELECT b1 FROM table_2 b WHERE b.xx = 'xx'), a.a2 = (SELECT b2 FROM table_2 b WHERE b.yy='yy');
Software Information:
- JSqlParser version 4.9
Tips:
Please write in English and avoid Screenshots (as we can't copy and paste content from it).
Try your example online with the latest JSQLParser and share the link in the error report.
Do provide Links or References to the specific Grammar and Syntax you are trying to use.
Metadata
Metadata
Assignees
Labels
No labels