From e19c8e0cae0b0299308dd6ee115af421502b7650 Mon Sep 17 00:00:00 2001 From: Terax <19204073+terax6669@users.noreply.github.com> Date: Sat, 21 Mar 2020 17:34:06 +0100 Subject: [PATCH 1/2] Fix model command to work with PdoFactory --- src/Builder/Component/Model.php | 5 ++++- src/Utils.php | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Builder/Component/Model.php b/src/Builder/Component/Model.php index 0ec1793b6..b7ae013cc 100644 --- a/src/Builder/Component/Model.php +++ b/src/Builder/Component/Model.php @@ -139,6 +139,9 @@ public function build(): void $adapterName = 'Phalcon\Db\Adapter\Pdo\\' . $adapter; unset($configArray['adapter']); + if (isset($configArray['options'])) { + $configArray = $configArray['options']; + } /** @var AbstractPdo $db */ $db = new $adapterName($configArray); @@ -623,7 +626,7 @@ protected function getEntityClassName(ReferenceInterface $reference, string $nam * @param AbstractPdo $db * @return array */ - protected function getReferenceList(string $schema, AbstractPdo $db): array + protected function getReferenceList(?string $schema, AbstractPdo $db): array { if ($this->modelOptions->hasOption('referenceList')) { return $this->modelOptions->getOption('referenceList'); diff --git a/src/Utils.php b/src/Utils.php index 8e6c207f1..a4dee30e8 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -17,9 +17,9 @@ class Utils { - const DB_ADAPTER_POSTGRESQL = 'Postgresql'; + const DB_ADAPTER_POSTGRESQL = 'postgresql'; - const DB_ADAPTER_SQLITE = 'Sqlite'; + const DB_ADAPTER_SQLITE = 'sqlite'; /** * Converts the underscore_notation to the UpperCamelCase @@ -107,11 +107,11 @@ public static function resolveDbSchema(Config $config) return $config->get('schema'); } - if (self::DB_ADAPTER_POSTGRESQL == $config->get('adapter')) { + if (self::DB_ADAPTER_POSTGRESQL === strtolower($config->get('adapter'))) { return 'public'; } - if (self::DB_ADAPTER_SQLITE == $config->get('adapter')) { + if (self::DB_ADAPTER_SQLITE === strtolower($config->get('adapter'))) { // SQLite only supports the current database, unless one is // attached. This is not the case, so don't return a schema. return null; From def31466f72877149ac1bf16f6315ed20adcada8 Mon Sep 17 00:00:00 2001 From: Terax <19204073+terax6669@users.noreply.github.com> Date: Sat, 21 Mar 2020 18:46:54 +0100 Subject: [PATCH 2/2] Tabs to spaces --- src/Builder/Component/Model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Builder/Component/Model.php b/src/Builder/Component/Model.php index b7ae013cc..a3806f447 100644 --- a/src/Builder/Component/Model.php +++ b/src/Builder/Component/Model.php @@ -139,9 +139,9 @@ public function build(): void $adapterName = 'Phalcon\Db\Adapter\Pdo\\' . $adapter; unset($configArray['adapter']); - if (isset($configArray['options'])) { - $configArray = $configArray['options']; - } + if (isset($configArray['options'])) { + $configArray = $configArray['options']; + } /** @var AbstractPdo $db */ $db = new $adapterName($configArray);