diff --git a/README.md b/README.md index 331033a..558c13b 100644 --- a/README.md +++ b/README.md @@ -2035,6 +2035,9 @@ In a nutshell: > > Every decimal version means that it patches/fixes/refactoring a previous functionality i.e. 1.5.0 -> 1.5.1 (fix) +* 3.1.6 2022-06-024 + * [CLI] solved a problem with the conversion per type of column + * [_BasePdoOneRepo] Fixed a problem with the conversion of the end results. * 3.1.5 2022-06-23 * [PdoOneQuery] Solved a bug when the cache is invalidated when insert(),update(), etc. * 3.1.4 2022-06-21 diff --git a/lib/PdoOne.php b/lib/PdoOne.php index 9166245..753f85e 100644 --- a/lib/PdoOne.php +++ b/lib/PdoOne.php @@ -25,11 +25,11 @@ * @package eftec * @author Jorge Castro Castillo * @copyright (c) Jorge Castro C. Dual Licence: MIT and Commercial License https://github.com/EFTEC/PdoOne - * @version 3.1.5 + * @version 3.1.6 */ class PdoOne { - public const VERSION = '3.1.5'; + public const VERSION = '3.1.6'; /** @var int We need this value because null and false could be a valid value. */ public const NULL = PHP_INT_MAX; /** @var string Prefix of the tables */ diff --git a/lib/PdoOneCli.php b/lib/PdoOneCli.php index ea11fad..7c84ac9 100644 --- a/lib/PdoOneCli.php +++ b/lib/PdoOneCli.php @@ -70,6 +70,7 @@ public function __construct() { $this->cli = new CliOne(); $this->cli->setErrorType(); + $this->conversion= $this->convertReset(); } public function getCli(): CliOne @@ -77,6 +78,13 @@ public function getCli(): CliOne return $this->cli; } + public function convertReset():array { + return ["bigint"=> null, "blob"=> null, "char"=> null, "date"=> null, "datetime"=> null, + "decimal"=> null, "double"=> null, "enum"=> null, "float"=> null, "geometry"=> null, + "int"=> null, "json"=> null, "longblob"=> null, "mediumint"=> null, "mediumtext"=> null, + "set"=> null, "smallint"=> null, "text"=> null, "time"=> null, "timestamp"=> null, + "tinyint"=> null, "varbinary"=> null, "varchar"=> null, "year"=> null]; + } /*** * It finds the vendor path (where composer is located). @@ -349,7 +357,9 @@ public function cliEngine(): void $this->tablexclass = $data['tablexclass'] ?? []; $this->columnsTable = $data['columnsTable'] ?? []; $this->columnsAlias = $data['columnsAlias'] ?? []; - $this->conversion = $data['conversion'] ?? []; + $this->conversion = ($data['conversion']===null || count($data['conversion'])===0) + ? $this->convertReset() + : $data['conversion']; $this->alias = $data['alias'] ?? []; $this->extracolumn = $data['extracolumn'] ?? []; $this->removecolumn = $config['removecolumn'] ?? []; @@ -771,11 +781,12 @@ protected function databaseConfigureRemove($ktable): void $this->cli->downLevel(); } - protected function databaseConvertXType(): void + protected function databaseConfigureXType(): void { - $this->cli->upLevel('convertxtype'); + $this->cli->upLevel('configuretype'); while (true) { $this->cli->setColor(['byellow'])->showBread(); + $this->cli->getParameter('convertionselected') ->setInput(true, 'option3', $this->conversion); $convertionselected = $this->cli->evalParam('convertionselected', true); @@ -903,7 +914,7 @@ protected function runCliGenerationParams(): void 'scan' => 'Scan for changes to the database. It adds or removes tables and classes', 'select' => 'Select or de-select the tables to work', 'detail' => 'Configure each table and columns separately', - 'convertxtype' => 'Configure all columns per type of data', + 'configuretype' => 'Configure all columns per type of data', 'save' => 'Save the current configuration', 'convert' => 'Convert and exit (in non-interactive mode is done automatically)']) ->add(); @@ -1073,8 +1084,8 @@ protected function runCliGeneration(): void case 'save': $this->databaseSave(); break; - case 'convertxtype': - $this->databaseConvertXType(); + case 'configuretype': + $this->databaseConfigureXType(); break; case 'select': $this->databaseSelect($tablesmarked, $tables); diff --git a/lib/_BasePdoOneRepo.php b/lib/_BasePdoOneRepo.php index 986e9cc..7d0bca8 100644 --- a/lib/_BasePdoOneRepo.php +++ b/lib/_BasePdoOneRepo.php @@ -679,6 +679,16 @@ public static function executePlan0(PdoOneQuery $currentQuery, ?array $condition $usingCacheFamily = ''; } $rowc = self::executePlan($currentQuery, '', $conditions, $currentQuery->getRecursive(), $first); + /** @var CustomerRepo $cls */ + $cls=self::class; + if($first) { + $cls::convertOutputVal($rowc); + } else { + foreach($rowc as $k=>$v) { + $cls::convertOutputVal($rowc[$k]); + } + } + if ($rowc !== false && $usingCache !== false) { $currentQuery->parent->getCacheService()->setCache(static::$uid, $usingCacheFamily, $rowc, $usingCache); }