Loading src/UnicaenDbImport/CodeGenerator/CodeGenerator.php +11 −8 Original line number Diff line number Diff line Loading @@ -375,8 +375,10 @@ abstract class CodeGenerator implements CodeGeneratorInterface /** * @return string */ public function generateSQLForSelectingInImportObservTable() public function generateSQLForSelectingInImportObservTable(string $table): string { $requiredValueForEnabled = $this->tableHelper->platformSupportsBooleanType() ? 'true' : 1; return <<<EOS select id, Loading @@ -388,7 +390,8 @@ select to_value, filter from import_observ io where io.operation = 'UPDATE' and io.enabled = 1 where io.operation = 'UPDATE' and io.enabled = $requiredValueForEnabled and table_name = '$table' order by operation, table_name, column_name EOS; } Loading @@ -398,13 +401,13 @@ EOS; * @param string $where * @return string */ protected function generateSQLForSelectingDiffViewFromImportObservRow(array $importObservRow, $where = null) protected function generateSQLForSelectingDiffViewFromImportObservRow(array $importObservRow, $where = null): string { $id = $importObservRow['id']; $tableName = $importObservRow['tableName']; $columnName = $importObservRow['columnName']; $toValue = $importObservRow['toValue']; $filter = $importObservRow['filter']; $id = $importObservRow['id'] ?? $importObservRow['ID']; $tableName = $importObservRow['table_name'] ?? $importObservRow['TABLE_NAME']; $columnName = $importObservRow['column_name'] ?? $importObservRow['COLUMN_NAME']; $toValue = $importObservRow['to_value'] ?? $importObservRow['TO_VALUE']; $filter = $importObservRow['filter'] ?? $importObservRow['FILTER']; // Construction du nom de la colonne de la vue V_DIFF_X indiquant un changement de valeur dans la table X. // Ex: 'U_RESULTAT' (dans la vue V_DIFF_THESE, indiquant que la colonne THESE.RESULTAT a changé). Loading src/UnicaenDbImport/CodeGenerator/Helper.php +10 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,16 @@ abstract class Helper */ protected $platform; /** * @return bool */ public function platformSupportsBooleanType(): bool { return $this->platform->getBooleanTypeDeclarationSQL([]) === 'BOOLEAN' || $this->platform->getBooleanTypeDeclarationSQL([]) === 'boolean'; } /** * @param string $argument * @return string Loading src/UnicaenDbImport/CodeGenerator/Helper/LogTableHelper.php +3 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ EOT; break; } $success = $result->getFailure() ? 0 : 1; if ($this->platformSupportsBooleanType()) { $success = $success ? 'true' : 'false'; } $startDate = $result->getStartDate()->format("Y-m-d H:i:s"); $endDate = $result->getEndDate()->format("Y-m-d H:i:s"); Loading src/UnicaenDbImport/CodeGenerator/Helper/TableHelper.php +3 −1 Original line number Diff line number Diff line Loading @@ -217,6 +217,8 @@ EOT; $deletedOnColumn = $this->config->getHistoColumnAliasForDeletedOn(); $requiredValueForImportable = $this->platformSupportsBooleanType() ? 'true' : 0; return <<<EOT with diff as ( SELECT Loading @@ -236,7 +238,7 @@ with diff as ( $destColumsSql FROM $destinationTable d JOIN source src ON src.id = d.source_id AND src.importable = 1 JOIN source src ON src.id = d.source_id AND src.importable = $requiredValueForImportable FULL OUTER JOIN $diffSourceTableName s ON s.source_id = d.source_id AND s.$sourceCodeColumn = d.$sourceCodeColumn ) select * from diff Loading src/UnicaenDbImport/CodeGenerator/Helper/TableValidationHelper.php +5 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenDbImport\CodeGenerator\Helper; use Doctrine\DBAL\DBALException; use InvalidArgumentException; use UnicaenApp\Exception\RuntimeException; use UnicaenDbImport\CodeGenerator\Helper; Loading Loading @@ -33,6 +34,10 @@ abstract class TableValidationHelper extends Helper */ public function convertTableExistenceCheckResultToBoolean(array $result) { if (! isset($result[0])) { throw new InvalidArgumentException("Données fournies non exploitables"); } $value = array_pop($result[0]); // NB: on ignore le nom de la colonne car la casse est incertaine return intval($value) === 1; Loading Loading
src/UnicaenDbImport/CodeGenerator/CodeGenerator.php +11 −8 Original line number Diff line number Diff line Loading @@ -375,8 +375,10 @@ abstract class CodeGenerator implements CodeGeneratorInterface /** * @return string */ public function generateSQLForSelectingInImportObservTable() public function generateSQLForSelectingInImportObservTable(string $table): string { $requiredValueForEnabled = $this->tableHelper->platformSupportsBooleanType() ? 'true' : 1; return <<<EOS select id, Loading @@ -388,7 +390,8 @@ select to_value, filter from import_observ io where io.operation = 'UPDATE' and io.enabled = 1 where io.operation = 'UPDATE' and io.enabled = $requiredValueForEnabled and table_name = '$table' order by operation, table_name, column_name EOS; } Loading @@ -398,13 +401,13 @@ EOS; * @param string $where * @return string */ protected function generateSQLForSelectingDiffViewFromImportObservRow(array $importObservRow, $where = null) protected function generateSQLForSelectingDiffViewFromImportObservRow(array $importObservRow, $where = null): string { $id = $importObservRow['id']; $tableName = $importObservRow['tableName']; $columnName = $importObservRow['columnName']; $toValue = $importObservRow['toValue']; $filter = $importObservRow['filter']; $id = $importObservRow['id'] ?? $importObservRow['ID']; $tableName = $importObservRow['table_name'] ?? $importObservRow['TABLE_NAME']; $columnName = $importObservRow['column_name'] ?? $importObservRow['COLUMN_NAME']; $toValue = $importObservRow['to_value'] ?? $importObservRow['TO_VALUE']; $filter = $importObservRow['filter'] ?? $importObservRow['FILTER']; // Construction du nom de la colonne de la vue V_DIFF_X indiquant un changement de valeur dans la table X. // Ex: 'U_RESULTAT' (dans la vue V_DIFF_THESE, indiquant que la colonne THESE.RESULTAT a changé). Loading
src/UnicaenDbImport/CodeGenerator/Helper.php +10 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,16 @@ abstract class Helper */ protected $platform; /** * @return bool */ public function platformSupportsBooleanType(): bool { return $this->platform->getBooleanTypeDeclarationSQL([]) === 'BOOLEAN' || $this->platform->getBooleanTypeDeclarationSQL([]) === 'boolean'; } /** * @param string $argument * @return string Loading
src/UnicaenDbImport/CodeGenerator/Helper/LogTableHelper.php +3 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ EOT; break; } $success = $result->getFailure() ? 0 : 1; if ($this->platformSupportsBooleanType()) { $success = $success ? 'true' : 'false'; } $startDate = $result->getStartDate()->format("Y-m-d H:i:s"); $endDate = $result->getEndDate()->format("Y-m-d H:i:s"); Loading
src/UnicaenDbImport/CodeGenerator/Helper/TableHelper.php +3 −1 Original line number Diff line number Diff line Loading @@ -217,6 +217,8 @@ EOT; $deletedOnColumn = $this->config->getHistoColumnAliasForDeletedOn(); $requiredValueForImportable = $this->platformSupportsBooleanType() ? 'true' : 0; return <<<EOT with diff as ( SELECT Loading @@ -236,7 +238,7 @@ with diff as ( $destColumsSql FROM $destinationTable d JOIN source src ON src.id = d.source_id AND src.importable = 1 JOIN source src ON src.id = d.source_id AND src.importable = $requiredValueForImportable FULL OUTER JOIN $diffSourceTableName s ON s.source_id = d.source_id AND s.$sourceCodeColumn = d.$sourceCodeColumn ) select * from diff Loading
src/UnicaenDbImport/CodeGenerator/Helper/TableValidationHelper.php +5 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace UnicaenDbImport\CodeGenerator\Helper; use Doctrine\DBAL\DBALException; use InvalidArgumentException; use UnicaenApp\Exception\RuntimeException; use UnicaenDbImport\CodeGenerator\Helper; Loading Loading @@ -33,6 +34,10 @@ abstract class TableValidationHelper extends Helper */ public function convertTableExistenceCheckResultToBoolean(array $result) { if (! isset($result[0])) { throw new InvalidArgumentException("Données fournies non exploitables"); } $value = array_pop($result[0]); // NB: on ignore le nom de la colonne car la casse est incertaine return intval($value) === 1; Loading