Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two bug fixes for sqlite3 database connector #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dm-coding
Copy link

  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

* 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test case is easier to read than an inline comment, and would help prevent a future regression.

@AD7six
Copy link
Member

AD7six commented Feb 17, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants