datasources icon indicating copy to clipboard operation
datasources copied to clipboard

Two bug fixes for sqlite3 database connector

Open dm-coding opened this issue 12 years ago • 1 comments

  1. In the first instance, an invalid database configuration can sometimes result in a failure to connect to the SQLite database without an error. As no error is caught by CakePhP, PhP itself throws a fatal error on line 221 as no $connection object exists. This bug fix forces the _execute() function to check that the database is in fact connected - if not, CakePhP gracefully throws a helpful error message to the user.

Reported here: http://stackoverflow.com/questions/4779007/cakephp-and-sqlite-fatal-error-call-to-a-member-function-query-on-a-non-obje, here: http://stackoverflow.com/questions/7107996/fatal-error-call-to-a-member-function-query-on-a-non-object-in-var-www-likes, and here: http://stackoverflow.com/questions/7572091/error-while-trying-to-connect-to-sqlite3-database-from-cakephp To reproduce: set $config['connect'] to an invalid value.

  1. In the second instance, the sqlite driver ignores SQL views. Changing the SQL query to read "SELECT name FROM sqlite_master WHERE type='table' OR type='view'" where it previously read just "type='table'" fixes this problem.

All the best,

Daniel

dm-coding avatar Mar 26 '12 21:03 dm-coding

In the first instance, an invalid database configuration can sometimes result in a failure to connect to the SQLite database without an error.

Is this point still relevant? if the config is invalid what should happen is to fail early so the developer can fix their config.

I've created a seperate 1 line PR (#100) for the second point.

AD7six avatar Feb 17 '14 09:02 AD7six