diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 50327a72..10ebc58e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1359,9 +1359,6 @@ $tables[$thisDb][$expr->table] - - $tables[$thisDb] - diff --git a/src/Utils/Misc.php b/src/Utils/Misc.php index f4e0bcd8..97a9ca81 100644 --- a/src/Utils/Misc.php +++ b/src/Utils/Misc.php @@ -68,6 +68,10 @@ public static function getAliases($statement, $database) ]; } + if (null === $expr->alias || $expr->alias === '') { + continue; + } + if (! isset($tables[$thisDb])) { $tables[$thisDb] = []; } diff --git a/tests/Utils/MiscTest.php b/tests/Utils/MiscTest.php index 192b22c3..6c775ccb 100644 --- a/tests/Utils/MiscTest.php +++ b/tests/Utils/MiscTest.php @@ -132,6 +132,25 @@ public static function getAliasesProvider(): array ], ], ], + [ + 'SELECT mytable.a x, o.b y FROM mytable JOIN other o ON o.id = mytable.id', + 'shop', + [ + 'shop' => [ + 'alias' => null, + 'tables' => [ + 'mytable' => [ + 'alias' => null, + 'columns' => ['a' => 'x'], + ], + 'other' => [ + 'alias' => 'o', + 'columns' => ['b' => 'y'], + ], + ], + ], + ], + ], ]; } }