Loading config/unicaen-db-import.global.php.dist +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ namespace Application; use \UnicaenDbImport\Entity\Db\Source; use UnicaenDbImport\Entity\Db\Source; return [ 'import' => [ Loading src/UnicaenDbImport/CodeGenerator/Helper/LogTableHelper.php +2 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ abstract class LogTableHelper extends Helper */ public function generateSQLForLogTableCreation(string $logTableName): string { $varchar = $this->platform->getVarcharTypeDeclarationSQL(['length' => 128]); $varchar = $this->platform->getStringTypeDeclarationSQL(['length' => 128]); $boolean = $this->platform->getBooleanTypeDeclarationSQL([]); $text = $this->platform->getClobTypeDeclarationSQL([]); try { Loading Loading @@ -91,8 +91,7 @@ EOT; throw new HelperException("Erreur lors de la génération du hash !", null, $e); } $sql = ''; $sql .= "INSERT INTO $logTableName (type, name, success, has_problems, log, started_on, ended_on, import_hash) "; $sql = "INSERT INTO $logTableName (type, name, success, has_problems, log, started_on, ended_on, import_hash) "; $sql .= sprintf("VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", $this->platform->quoteStringLiteral($type), $this->platform->quoteStringLiteral($name), Loading src/UnicaenDbImport/CodeGenerator/Helper/TableHelper.php +6 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ namespace UnicaenDbImport\CodeGenerator\Helper; use DateTime; use DateTimeZone; use stdClass; use UnicaenApp\Exception\RuntimeException; use UnicaenDbImport\CodeGenerator\Helper; use UnicaenDbImport\Domain\Operation; Loading Loading @@ -477,9 +480,9 @@ EOT; return 'NULL'; } if ($value instanceof \stdClass) { if ($value instanceof stdClass) { if (isset($value->date)) { $tz = isset($value->timezone) ? new \DateTimeZone($value->timezone) : NULL; $tz = isset($value->timezone) ? new DateTimeZone($value->timezone) : NULL; $d = date_create($value->date, $tz); return $this->formatDateTimeForInsert($d); Loading @@ -497,7 +500,7 @@ EOT; * @param \DateTime $value * @return string */ protected function formatDateTimeForInsert(\DateTime $value): string protected function formatDateTimeForInsert(DateTime $value): string { $value = $value->format('c'); Loading src/UnicaenDbImport/CodeGenerator/Helper/TableValidationHelper.php +1 −1 Original line number Diff line number Diff line Loading @@ -203,7 +203,7 @@ EOT; } $integer = $this->platform->getBigIntTypeDeclarationSQL([]); $varchar = $this->platform->getVarcharTypeDeclarationSQL(['length' => 100]); $varchar = $this->platform->getStringTypeDeclarationSQL(['length' => 100]); $message = "Assurez-vous que les colonnes suivantes sont présentes dans la table '$tableName' : " . PHP_EOL; $message .= <<<EOT Loading src/UnicaenDbImport/CodeGenerator/Oracle/Helper/TableHelper.php +3 −8 Original line number Diff line number Diff line Loading @@ -45,10 +45,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper */ public function generateSQLForDiffViewCreation(string $diffSourceTableName, string $destinationTable, string $sourceCodeColumn, array $columns): string { $res = ''; $res .= $this->generateDiffViewCreationSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns) . PHP_EOL; return $res; return $this->generateDiffViewCreationSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns) . PHP_EOL; } /** Loading @@ -62,8 +59,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper { $name = $this->generateDiffViewName($destinationTable); $res = ''; $res .= "CREATE OR REPLACE VIEW $name AS " . PHP_EOL; $res = "CREATE OR REPLACE VIEW $name AS " . PHP_EOL; $res .= $this->indent(4, $this->generateDiffViewBodySelectSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns)) . PHP_EOL; return $res; Loading Loading @@ -122,8 +118,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper $where = "diff.operation = '$operation' AND d.$sourceCodeColumn = diff.$sourceCodeColumn"; // instruction de mise à jour de la table destination $markup = ''; $markup .= "MERGE INTO $destinationTable d USING (SELECT * FROM $diffViewName) diff " . PHP_EOL; $markup = "MERGE INTO $destinationTable d USING (SELECT * FROM $diffViewName) diff " . PHP_EOL; $markup .= "ON ($where) " . PHP_EOL; $markup .= "WHEN MATCHED THEN UPDATE SET " . PHP_EOL; $markup .= $setters; Loading Loading
config/unicaen-db-import.global.php.dist +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ namespace Application; use \UnicaenDbImport\Entity\Db\Source; use UnicaenDbImport\Entity\Db\Source; return [ 'import' => [ Loading
src/UnicaenDbImport/CodeGenerator/Helper/LogTableHelper.php +2 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ abstract class LogTableHelper extends Helper */ public function generateSQLForLogTableCreation(string $logTableName): string { $varchar = $this->platform->getVarcharTypeDeclarationSQL(['length' => 128]); $varchar = $this->platform->getStringTypeDeclarationSQL(['length' => 128]); $boolean = $this->platform->getBooleanTypeDeclarationSQL([]); $text = $this->platform->getClobTypeDeclarationSQL([]); try { Loading Loading @@ -91,8 +91,7 @@ EOT; throw new HelperException("Erreur lors de la génération du hash !", null, $e); } $sql = ''; $sql .= "INSERT INTO $logTableName (type, name, success, has_problems, log, started_on, ended_on, import_hash) "; $sql = "INSERT INTO $logTableName (type, name, success, has_problems, log, started_on, ended_on, import_hash) "; $sql .= sprintf("VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", $this->platform->quoteStringLiteral($type), $this->platform->quoteStringLiteral($name), Loading
src/UnicaenDbImport/CodeGenerator/Helper/TableHelper.php +6 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ namespace UnicaenDbImport\CodeGenerator\Helper; use DateTime; use DateTimeZone; use stdClass; use UnicaenApp\Exception\RuntimeException; use UnicaenDbImport\CodeGenerator\Helper; use UnicaenDbImport\Domain\Operation; Loading Loading @@ -477,9 +480,9 @@ EOT; return 'NULL'; } if ($value instanceof \stdClass) { if ($value instanceof stdClass) { if (isset($value->date)) { $tz = isset($value->timezone) ? new \DateTimeZone($value->timezone) : NULL; $tz = isset($value->timezone) ? new DateTimeZone($value->timezone) : NULL; $d = date_create($value->date, $tz); return $this->formatDateTimeForInsert($d); Loading @@ -497,7 +500,7 @@ EOT; * @param \DateTime $value * @return string */ protected function formatDateTimeForInsert(\DateTime $value): string protected function formatDateTimeForInsert(DateTime $value): string { $value = $value->format('c'); Loading
src/UnicaenDbImport/CodeGenerator/Helper/TableValidationHelper.php +1 −1 Original line number Diff line number Diff line Loading @@ -203,7 +203,7 @@ EOT; } $integer = $this->platform->getBigIntTypeDeclarationSQL([]); $varchar = $this->platform->getVarcharTypeDeclarationSQL(['length' => 100]); $varchar = $this->platform->getStringTypeDeclarationSQL(['length' => 100]); $message = "Assurez-vous que les colonnes suivantes sont présentes dans la table '$tableName' : " . PHP_EOL; $message .= <<<EOT Loading
src/UnicaenDbImport/CodeGenerator/Oracle/Helper/TableHelper.php +3 −8 Original line number Diff line number Diff line Loading @@ -45,10 +45,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper */ public function generateSQLForDiffViewCreation(string $diffSourceTableName, string $destinationTable, string $sourceCodeColumn, array $columns): string { $res = ''; $res .= $this->generateDiffViewCreationSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns) . PHP_EOL; return $res; return $this->generateDiffViewCreationSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns) . PHP_EOL; } /** Loading @@ -62,8 +59,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper { $name = $this->generateDiffViewName($destinationTable); $res = ''; $res .= "CREATE OR REPLACE VIEW $name AS " . PHP_EOL; $res = "CREATE OR REPLACE VIEW $name AS " . PHP_EOL; $res .= $this->indent(4, $this->generateDiffViewBodySelectSQLSnippet($diffSourceTableName, $destinationTable, $sourceCodeColumn, $columns)) . PHP_EOL; return $res; Loading Loading @@ -122,8 +118,7 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper $where = "diff.operation = '$operation' AND d.$sourceCodeColumn = diff.$sourceCodeColumn"; // instruction de mise à jour de la table destination $markup = ''; $markup .= "MERGE INTO $destinationTable d USING (SELECT * FROM $diffViewName) diff " . PHP_EOL; $markup = "MERGE INTO $destinationTable d USING (SELECT * FROM $diffViewName) diff " . PHP_EOL; $markup .= "ON ($where) " . PHP_EOL; $markup .= "WHEN MATCHED THEN UPDATE SET " . PHP_EOL; $markup .= $setters; Loading