@@ -539,19 +539,19 @@ void testTableRenamingIssue2028() throws JSQLParserException {
539539 ";" ;
540540 //@formatter:on
541541
542- TablesNamesFinder finder = new TablesNamesFinder <Void >() {
542+ TablesNamesFinder < Void > finder = new TablesNamesFinder <>() {
543543 @ 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 ();
546546 if (schemaName != null && IGNORE_SCHEMAS .contains (schemaName .toLowerCase ())) {
547- return super .visit (tableName , context );
547+ return super .visit (table , context );
548548 }
549- String originTableName = tableName .getName ();
550- tableName .setName (prefix + originTableName );
549+ String originTableName = table .getName ();
550+ table .setName (prefix + originTableName );
551551 if (originTableName .startsWith ("`" )) {
552- tableName .setName ("`" + prefix + originTableName .replace ("`" , "" ) + "`" );
552+ table .setName ("`" + prefix + originTableName .replace ("`" , "" ) + "`" );
553553 }
554- return super .visit (tableName , context );
554+ return super .visit (table , context );
555555 }
556556 };
557557 finder .init (false );
@@ -561,5 +561,17 @@ public <S> Void visit(Table tableName, S context) {
561561
562562 TestUtils .assertStatementCanBeDeparsedAs (statement , expected , true );
563563 }
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+ }
564576}
565577
0 commit comments