nette / database

💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
https://doc.nette.org/database
Other
513 stars 108 forks source link

SQLiteDriver exception from getForeignKeys - incorrect results from PRAGMA foreign_key_list #281

Closed SlavaAurim closed 2 years ago

SlavaAurim commented 3 years ago

This line throws exception: https://github.com/nette/database/blob/568b7c98608c3883d78a349bf016c41fb8f10dfb/src/Database/Drivers/SqliteDriver.php#L211

...because my sqlite (in php 8) return NULL in column 'to' in results from PRAGMA foreign_key_list(tablename) Another columns has correct data.

This is simple fix:

if ($keys[$row['id']]['foreign'] //<== check if equal null
        && $keys[$row['id']]['foreign'][0] == null) {
        $keys[$row['id']]['foreign'] = null;        
}