bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.