You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: SQLite tableExists() does not find a view #17768
Describe the bug
On SQLite, tableExists() gives false for a view. On MySQL, MariaDB and PostgreSQL it gives true for a view: those dialects read information_schema.tables, which also lists the views. The SQLite dialect reads only type='table' from sqlite_master (phalcon/Db/Dialect/Sqlite.zep, tableExists()).
The fix changes the result of tableExists() on SQLite, so it is for 7.0.
To Reproduce
$connection->execute('CREATE TABLE t1 (id INTEGER PRIMARY KEY)');
$connection->execute('CREATE VIEW v1 AS SELECT id FROM t1');
var_dump($connection->tableExists('v1')); // SQLite: falsevar_dump($connection->viewExists('v1')); // SQLite: true
The query of the MySQL dialect gives 1 for v1 on MariaDB 10.6.28, and the query of the PostgreSQL dialect gives 1 on PostgreSQL 18.7.
Expected behavior tableExists() gives the same result for a view on each adapter. A possible fix: type IN ('table', 'view') in the SQLite dialect.
Details
Phalcon version: 5.0.x (cfcf481836). phalcon/phalcon v6.0.x has the same query (src/Db/Dialect/Sqlite.php).
Additional context
Found in phalcon/crest#88: crest make:model <view> stops on SQLite only. Until this changes, crest also calls viewExists().
Activity