-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
PostgreSQL support - proposal n.1: without change in database schema #494
Conversation
CodeIgniter 4.1.x will still support PHP 7.3 but the This looks like a good PR; I am surprised that a library needs modification to support a supported database driver though. I have no experience with Postgres - is this something that the framework is handling poorly? Or some niche case here? |
Thanks for reviewing it. Glad to hear that PHP 7.3 will still be supported a little bit longer. This is often noted by big organizations which struggle to keep the pace of other frameworks. About the problem, well... both boolean fields and PostgreSQL are kinda rarely used in the PHP ecosystem, so you have a choice between :
Actually, CodeIgniter may have this kind of a bug (see #495 where I have to avoid --- a/src/Controllers/AuthController.php
+++ b/src/Controllers/AuthController.php
@@ -345,7 +345,7 @@ public function attemptReset()
$user->reset_hash = null;
$user->reset_at = date('Y-m-d H:i:s');
$user->reset_expires = null;
- $user->force_pass_reset = false;
+ $user->force_pass_reset = 0;
$users->save($user);
return redirect()->route('login')->with('message', lang('Auth.resetSuccess')); However, this pull-request and its setters may help the absent-minded developers :) |
I'm not opposed to this change, but I'm surprised having those fields cast as booleans isn't already converting that. Been a long time since I've looked at that code in the model, though. And a huge thank you for updating the tests to run on MySQL and Postgres also. |
Update on the failed tests: it seems to come from some other test calling Ponctual correction in f94f4c5 but a more global approach, covering all the test classes, may be preferable: --- a/tests/_support/AuthTestCase.php
+++ b/tests/_support/AuthTestCase.php
@@ -7,6 +7,7 @@
use Faker\Generator;
use Myth\Auth\Authorization\GroupModel;
use Myth\Auth\Authorization\PermissionModel;
+use Myth\Auth\Config\Services;
use Myth\Auth\Entities\User;
use Myth\Auth\Models\UserModel;
use Myth\Auth\Test\AuthTestTrait;
@@ -67,6 +68,15 @@ class AuthTestCase extends CIUnitTestCase
*/
protected $faker;
+ public static function setUpBeforeClass(): void
+ {
+ parent::setUpBeforeClass();
+
+ // Some tests call Services::reset() which, contrary to
+ // Services::reset(true), discards a lot of services.
+ Services::reset(true);
+ }
+
protected function setUp(): void
{
parent::setUp(); Note to self: it was transient because we use |
(on top of the run with SQLite)
…ict DB This patch doesn't modify the database schema and, instead, forcibly converts booleans to integers. Another way of fixing lonnieezell#324 would be to use booleans at the database level : the code change is bigger but, since MySQL & MariaDB would implictly convert to tinyint and SQLite isn't typed, the impact on existing deployments may still be acceptable.
FIXME: should we clean up and force a proper (int) ?
Those patches add support for PostgreSQL database : they doesn't modify the database schema but, instead, forcibly convert the booleans attributes' values of the entity to integers (see the 2 setters).
Tests added to run on MySQL and PostgreSQL (on top of already running on SQLite). Since it seems that CodeIgniter 4.1.x sadly doesn't support PHP 7.3 anymore, I removed it from the tests' matrix.
Those patches also fix a couple of typos.