Loading test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/TableValidationHelperTest.php +3 −3 Changes for test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/TableValidationHelperTest.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -72,9 +72,9 @@ EOT; { $sql = $this->tableValidation->generateSQLForHistoColumnsValidation('table'); $expected = <<<EOT SELECT 'created_on', 'timestamp with time zone' UNION SELECT 'updated_on', 'timestamp with time zone' UNION SELECT 'deleted_on', 'timestamp with time zone' SELECT 'created_on', 'timestamptz' UNION SELECT 'updated_on', 'timestamptz' UNION SELECT 'deleted_on', 'timestamptz' EOT; $this->assertContains($expected, $sql); } Loading test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/expected_function_creation_sql.sql +7 −0 Changes for test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/expected_function_creation_sql.sql: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ DECLARE operation VARCHAR(64); sql TEXT; BEGIN -- l'enregistrement existe dans la source mais pas dans la destination : il devra être ajouté IF (src_code IS NOT NULL AND dest_code IS NULL) THEN operation = 'insert'; sql = concat('INSERT INTO ztemptable(code, libelle, debut_validite, fin_validite) VALUES ($$', src_code, '$$, $$', src_libelle, '$$, $$', src_debut_validite, '$$, $$', src_fin_validite, '$$) ;'); Loading @@ -15,19 +16,23 @@ BEGIN INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('insert', 'ztemptable', src_code, null, null, null, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- l'enregistrement existe dans la destination et n'est pas historisé IF (src_code IS NOT NULL AND dest_code IS NOT NULL and dest_deleted_on IS NULL) THEN -- 'libelle' doit être mis à jour IF (src_libelle <> dest_libelle) THEN operation = 'update'; sql = concat('UPDATE ztemptable SET libelle = $$', src_libelle, '$$, updated_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); sql = concat(sql, ' UPDATE import_reg SET executed_on = LOCALTIMESTAMP(0) WHERE import_hash = ''', import_hash, ''' ;'); INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('update', 'ztemptable', src_code, 'libelle', src_libelle, dest_libelle, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- 'debut_validite' doit être mis à jour IF (src_debut_validite <> dest_debut_validite) THEN operation = 'update'; sql = concat('UPDATE ztemptable SET debut_validite = $$', src_debut_validite, '$$, updated_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); sql = concat(sql, ' UPDATE import_reg SET executed_on = LOCALTIMESTAMP(0) WHERE import_hash = ''', import_hash, ''' ;'); INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('update', 'ztemptable', src_code, 'debut_validite', src_debut_validite, dest_debut_validite, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- 'fin_validite' doit être mis à jour IF (src_fin_validite <> dest_fin_validite) THEN operation = 'update'; sql = concat('UPDATE ztemptable SET fin_validite = $$', src_fin_validite, '$$, updated_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); Loading @@ -37,6 +42,7 @@ BEGIN END IF; -- l'enregistrement existe dans la destination mais historisé : il sera dé-historisé IF (src_code IS NOT NULL AND dest_code IS NOT NULL and dest_deleted_on IS NOT NULL) THEN operation = 'undelete'; sql = concat('UPDATE ztemptable SET libelle = $$', src_libelle, '$$, debut_validite = $$', src_debut_validite, '$$, fin_validite = $$', src_fin_validite, '$$, updated_on = LOCALTIMESTAMP(0), deleted_on = null WHERE code = $$', dest_code, '$$ ;'); Loading @@ -44,6 +50,7 @@ BEGIN INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('undelete', 'ztemptable', src_code, null, null, null, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- l'enregistrement existe dans la destination mais plus dans la source : il sera historisé IF (src_code IS NULL AND dest_code IS NOT NULL and dest_deleted_on IS NULL) THEN operation = 'delete'; sql = concat('UPDATE ztemptable SET deleted_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); Loading Loading
test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/TableValidationHelperTest.php +3 −3 Changes for test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/TableValidationHelperTest.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -72,9 +72,9 @@ EOT; { $sql = $this->tableValidation->generateSQLForHistoColumnsValidation('table'); $expected = <<<EOT SELECT 'created_on', 'timestamp with time zone' UNION SELECT 'updated_on', 'timestamp with time zone' UNION SELECT 'deleted_on', 'timestamp with time zone' SELECT 'created_on', 'timestamptz' UNION SELECT 'updated_on', 'timestamptz' UNION SELECT 'deleted_on', 'timestamptz' EOT; $this->assertContains($expected, $sql); } Loading
test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/expected_function_creation_sql.sql +7 −0 Changes for test/UnicaenDbImportUnitTest/CodeGenerator/PostgreSQL/Helper/expected_function_creation_sql.sql: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ DECLARE operation VARCHAR(64); sql TEXT; BEGIN -- l'enregistrement existe dans la source mais pas dans la destination : il devra être ajouté IF (src_code IS NOT NULL AND dest_code IS NULL) THEN operation = 'insert'; sql = concat('INSERT INTO ztemptable(code, libelle, debut_validite, fin_validite) VALUES ($$', src_code, '$$, $$', src_libelle, '$$, $$', src_debut_validite, '$$, $$', src_fin_validite, '$$) ;'); Loading @@ -15,19 +16,23 @@ BEGIN INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('insert', 'ztemptable', src_code, null, null, null, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- l'enregistrement existe dans la destination et n'est pas historisé IF (src_code IS NOT NULL AND dest_code IS NOT NULL and dest_deleted_on IS NULL) THEN -- 'libelle' doit être mis à jour IF (src_libelle <> dest_libelle) THEN operation = 'update'; sql = concat('UPDATE ztemptable SET libelle = $$', src_libelle, '$$, updated_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); sql = concat(sql, ' UPDATE import_reg SET executed_on = LOCALTIMESTAMP(0) WHERE import_hash = ''', import_hash, ''' ;'); INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('update', 'ztemptable', src_code, 'libelle', src_libelle, dest_libelle, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- 'debut_validite' doit être mis à jour IF (src_debut_validite <> dest_debut_validite) THEN operation = 'update'; sql = concat('UPDATE ztemptable SET debut_validite = $$', src_debut_validite, '$$, updated_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); sql = concat(sql, ' UPDATE import_reg SET executed_on = LOCALTIMESTAMP(0) WHERE import_hash = ''', import_hash, ''' ;'); INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('update', 'ztemptable', src_code, 'debut_validite', src_debut_validite, dest_debut_validite, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- 'fin_validite' doit être mis à jour IF (src_fin_validite <> dest_fin_validite) THEN operation = 'update'; sql = concat('UPDATE ztemptable SET fin_validite = $$', src_fin_validite, '$$, updated_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); Loading @@ -37,6 +42,7 @@ BEGIN END IF; -- l'enregistrement existe dans la destination mais historisé : il sera dé-historisé IF (src_code IS NOT NULL AND dest_code IS NOT NULL and dest_deleted_on IS NOT NULL) THEN operation = 'undelete'; sql = concat('UPDATE ztemptable SET libelle = $$', src_libelle, '$$, debut_validite = $$', src_debut_validite, '$$, fin_validite = $$', src_fin_validite, '$$, updated_on = LOCALTIMESTAMP(0), deleted_on = null WHERE code = $$', dest_code, '$$ ;'); Loading @@ -44,6 +50,7 @@ BEGIN INSERT INTO import_reg(operation, table_name, source_code, field_name, to_value, from_value, sql, created_on, import_hash) VALUES ('undelete', 'ztemptable', src_code, null, null, null, sql, LOCALTIMESTAMP(0), import_hash); END IF; -- l'enregistrement existe dans la destination mais plus dans la source : il sera historisé IF (src_code IS NULL AND dest_code IS NOT NULL and dest_deleted_on IS NULL) THEN operation = 'delete'; sql = concat('UPDATE ztemptable SET deleted_on = LOCALTIMESTAMP(0) WHERE code = $$', dest_code, '$$ ;'); Loading