Skip to content

Commit 4845338

Browse files
committed
Fix SQLiteParser in case when it tries to parse non-existing table
1 parent 36ae1fe commit 4845338

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Providers/SQLite/SQLiteParser.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SQLiteParser
1616
private const ENUM_PATTERN = '/check \((?:`|\"|\')?(\w+)(?:`|\"|\')? in \((.+)\)\)/i';
1717

1818
private readonly string $tableName;
19-
private readonly string $tableSql;
19+
private readonly ?string $tableSql;
2020
private readonly array $indexesSql;
2121

2222
public function __construct(
@@ -27,15 +27,18 @@ public function __construct(
2727
$this->tableSql = $connection->executeQuery(
2828
sql: self::TABLE_SQL,
2929
params: ['tableName' => $tableName],
30-
)->fetchOne();
30+
)->fetchOne() ?: null;
3131
$this->indexesSql = $connection->executeQuery(
3232
sql: self::INDEXES_SQL,
3333
params: ['tableName' => $tableName],
3434
)->fetchFirstColumn();
3535
}
3636

37-
public function getSQLTable(): AbstractSQLTable
37+
public function getSQLTable(): ?AbstractSQLTable
3838
{
39+
if (!$this->tableSql) {
40+
return null;
41+
}
3942
$columns = $enums = $primaryKeys = [];
4043
$columnsStarted = false;
4144
$lines = array_map(

0 commit comments

Comments
 (0)