@@ -539,19 +539,19 @@ void testTableRenamingIssue2028() throws JSQLParserException {
539
539
";" ;
540
540
//@formatter:on
541
541
542
- TablesNamesFinder finder = new TablesNamesFinder <Void >() {
542
+ TablesNamesFinder < Void > finder = new TablesNamesFinder <>() {
543
543
@ Override
544
- public <S > Void visit (Table tableName , S context ) {
545
- String schemaName = tableName .getSchemaName ();
544
+ public <S > Void visit (Table table , S context ) {
545
+ String schemaName = table .getSchemaName ();
546
546
if (schemaName != null && IGNORE_SCHEMAS .contains (schemaName .toLowerCase ())) {
547
- return super .visit (tableName , context );
547
+ return super .visit (table , context );
548
548
}
549
- String originTableName = tableName .getName ();
550
- tableName .setName (prefix + originTableName );
549
+ String originTableName = table .getName ();
550
+ table .setName (prefix + originTableName );
551
551
if (originTableName .startsWith ("`" )) {
552
- tableName .setName ("`" + prefix + originTableName .replace ("`" , "" ) + "`" );
552
+ table .setName ("`" + prefix + originTableName .replace ("`" , "" ) + "`" );
553
553
}
554
- return super .visit (tableName , context );
554
+ return super .visit (table , context );
555
555
}
556
556
};
557
557
finder .init (false );
@@ -561,5 +561,17 @@ public <S> Void visit(Table tableName, S context) {
561
561
562
562
TestUtils .assertStatementCanBeDeparsedAs (statement , expected , true );
563
563
}
564
+
565
+ @ Test
566
+ void testAlterTableIssue2062 () throws JSQLParserException {
567
+ String sqlStr = "ALTER TABLE the_cool_db.the_table\n "
568
+ + " ADD test VARCHAR (40)\n "
569
+ + ";" ;
570
+ Set <String > tables = TablesNamesFinder .findTablesOrOtherSources (sqlStr );
571
+ assertThat (tables ).containsExactlyInAnyOrder ("the_cool_db.the_table" );
572
+
573
+ tables = TablesNamesFinder .findTables (sqlStr );
574
+ assertThat (tables ).containsExactlyInAnyOrder ("the_cool_db.the_table" );
575
+ }
564
576
}
565
577
0 commit comments