-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Review and improvements in databases drivers MySQLi, Postgre and SQLite: #1335
Review and improvements in databases drivers MySQLi, Postgre and SQLite: #1335
Conversation
1) Fixed typo method name "escapeLikeStr()" to "escapeLikeString()". 2) Methods _fieldData(), _indexData() and _foreignKeyData() now return only array and throw DatabaseException (instead of returning false). 2.1) BaseConnection, added abstract methods() missing because this class relies on all its subclasses having those methods. 3) BaseBuilder, added TODO about a parameter with default value. 4) composer.json, added ext-mysqli at require-dev section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those to throw exceptions! The biggest thing I commented on here is for you to localize the strings thrown by the exceptions.
All of the other exception files use a different style for throwing exceptions. If you wanted to emulate what those were doing, that would be great, but I won't push that one since I obviously missed the DatabaseException class when I went through and converted those.
composer.json
Outdated
@@ -24,7 +24,8 @@ | |||
"require-dev": { | |||
"phpunit/phpunit": "^7.0", | |||
"mikey179/vfsStream": "1.6.*", | |||
"codeigniter4/codeigniter4-standard": "^1.0" | |||
"codeigniter4/codeigniter4-standard": "^1.0", | |||
"ext-mysqli": "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mysql driver is not needed if you plan on using Postgres. Please remove.
{ | ||
return FALSE; | ||
throw new DatabaseException('Failed to get field data from MySQL.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a localized string that is added to system/Language/en/Database.php
{ | ||
return FALSE; | ||
throw new DatabaseException('Failed to get index data from MySQL.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use localized string here.
@@ -488,7 +494,7 @@ public function _indexData(string $table) | |||
} | |||
else | |||
{ | |||
throw new \LogicException('parsing key string failed.'); | |||
throw new \LogicException('Parsing key string failed.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wouldn't mind moving this one to the Database lang file too, that would be great!
@@ -521,7 +528,7 @@ public function _foreignKeyData(string $table) | |||
|
|||
if (($query = $this->query($sql)) === false) | |||
{ | |||
return false; | |||
throw new DatabaseException('Failed to get foreign key data from MySQL'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localize this string
@@ -338,7 +341,7 @@ public function _indexData(string $table) | |||
|
|||
if (($query = $this->query($sql)) === false) | |||
{ | |||
return false; | |||
throw new DatabaseException('Failed to get index data from PostgreSQL.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localize this string
|
||
if (($query = $this->query($sql)) === false) | ||
{ | ||
return false; | ||
throw new DatabaseException('Failed to get foreign key data from PostgreSQL.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localize this string
if (($query = $this->query('PRAGMA TABLE_INFO('.$this->protectIdentifiers($table, true, null, | ||
false).')')) === false) | ||
{ | ||
return false; | ||
throw new DatabaseException('Failed to get field data from SQLite.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localize this string
if (($query = $this->query($sql)) === false) | ||
{ | ||
return false; | ||
throw new DatabaseException('Failed to get index data from SQLite.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localize this string
@@ -354,7 +353,7 @@ public function _indexData(string $table) | |||
$obj->fields = []; | |||
if (($fields = $this->query('PRAGMA index_info('.$this->escape(strtolower($row->name)).')')) === false) | |||
{ | |||
return false; | |||
throw new DatabaseException('Failed to get index_info() from SQLite.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Localize this string
Hi Lonnie thank you I'll do these improvements still this week. |
…ngs. 2) Language/en/Database.php, new entries about exceptions. 3) composer.json, removed ext-mysqli.
Hi there, I've done the modifications, thanks. |
Thanks! |
2.1) BaseConnection, added abstract methods() missing because this class relies on all its subclasses having those methods.