SQL support won't read schema of SQLite VIEWs, only TABLEs
julesfm opened this issue · comments
If an SQLite DB has a VIEW in it, the schema reader in sql.php doesn't see it as it only checks for
type='table'
This can be easily fixed with a patch to 1 line in sql.php that makes this change:
@@ -339,7 +339,8 @@
$cmd=[
'sqlite2?'=>[
'SELECT * FROM pragma_table_info('.$this->quote($table).') JOIN ('.
- 'SELECT sql FROM sqlite_master WHERE type=\'table\' AND '.
+// JKF THIS IS THE BUGFIX Added check for type=view
+ 'SELECT sql FROM sqlite_master WHERE (type=\'table\' OR type=\'view\') AND '.
'name='.$this->quote($table).')',
'name','type','dflt_value','notnull',0,'pk',TRUE,'sql',
'/\W(%s)\W+[^,]+?AUTOINCREMENT\W/i'],
This appears in the release version 3.7.3.
Many thanks!
Jules.
Commenting here, to give this issue some visibility, as per Rayne's comment on SO: https://stackoverflow.com/questions/68406656/why-are-f3-database-queries-on-views-not-working-with-sqlite/68484220?noredirect=1#comment121037372_68484220