diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php index 53654f397..1b4c07469 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveAccompanyingPeriodParticipationHandler.php @@ -34,11 +34,11 @@ class PersonMoveAccompanyingPeriodParticipationHandler implements PersonMoveSqlH WHERE person_id = %d AND (cpapp.startdate, COALESCE(cpapp.enddate, 'infinity'::date)) OVERLAPS (cpapp2.startdate, COALESCE(cpapp2.enddate, 'infinity'::date)) - ) + ); SQL, $to->getId(), $from->getId(), $to->getId()); $deleteSql = sprintf(<<<'SQL' - DELETE FROM chill_person_accompanying_period_participation WHERE person_id = %d + DELETE FROM chill_person_accompanying_period_participation WHERE person_id = %d; SQL, $from->getId()); return [$insertSql, $deleteSql]; diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php index c4307259f..e8e811f1b 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveCenterHistoryHandler.php @@ -52,12 +52,17 @@ class PersonMoveCenterHistoryHandler implements PersonMoveSqlHandlerInterface } } - $sqlDelete = sprintf("delete FROM chill_person_person_center_history WHERE person_id = %d", $from->getId()); + $sqlDelete = sprintf(<<<'SQL' + DELETE FROM chill_person_person_center_history WHERE person_id = %d; + SQL, $from->getId()); $sqlStatements = [$sqlDelete]; if ((null !== $oldestDateA && null !== $oldestDateB) && $oldestDateA <= $oldestDateB) { - $sqlInsert = sprintf("update chill_person_person_center_history set startDate = '%s' WHERE id = %d", $oldestDateA->format('Y-m-d'), $oldestCenterHistoryB->getId()); + + $sqlInsert = sprintf(<<<'SQL' + UPDATE chill_person_person_center_history SET startDate = '%s' WHERE id = %d; + SQL, $oldestDateA->format('Y-m-d'), $oldestCenterHistoryB->getId()); $sqlStatements = [$sqlInsert, $sqlDelete]; } diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php index 2b5514b9c..d617e12ed 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveHouseholdHandler.php @@ -34,11 +34,11 @@ class PersonMoveHouseholdHandler implements PersonMoveSqlHandlerInterface WHERE person_id = %d AND daterange(cphm.startdate, cphm.enddate) && daterange(cphm_inner.startdate, cphm_inner.enddate) - ) + ); SQL, $to->getId(), $from->getId(), $to->getId()); $deleteSql = sprintf(<<<'SQL' - DELETE FROM chill_person_household_members WHERE person_id = %d + DELETE FROM chill_person_household_members WHERE person_id = %d; SQL, $from->getId()); return [$sqlInsert, $deleteSql]; diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php index 82ca0592c..22c65a43d 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/Handler/PersonMoveRelationHandler.php @@ -34,7 +34,7 @@ class PersonMoveRelationHandler implements PersonMoveSqlHandlerInterface WHERE cpr2.fromperson_id = %d AND cpr2.toperson_id = %d OR cpr2.fromperson_id = %d AND cpr2.toperson_id = %d - ) + ); SQL, $from->getId(), $from->getId(), $to->getId(), $from->getId(), $from->getId(), $to->getId()); $deleteSql = sprintf(<<<'SQL' diff --git a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php index 067727078..8bce56c0e 100644 --- a/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php +++ b/src/Bundle/ChillPersonBundle/Actions/Remove/PersonMove.php @@ -107,11 +107,11 @@ class PersonMove $personMetadata = $this->em->getClassMetadata(Person::class); $sqls[] = sprintf( - 'DELETE FROM %s WHERE id = %d', + 'DELETE FROM %s WHERE id = %d;', $this->getTableName($personMetadata), $from->getId() ); - + return $sqls; } @@ -132,7 +132,7 @@ class PersonMove } return sprintf( - 'DELETE FROM %s WHERE %s', + 'DELETE FROM %s WHERE %s;', $this->getTableName($metadata), implode(' AND ', $conditions) ); @@ -153,7 +153,7 @@ class PersonMove . $mapping['joinTable']['name']; $sqlInsert = sprintf( - "INSERT INTO %s (%s, %s) SELECT %d, %s FROM %s WHERE %s = %d ON CONFLICT DO NOTHING", + "INSERT INTO %s (%s, %s) SELECT %d, %s FROM %s WHERE %s = %d ON CONFLICT DO NOTHING;", $tableName, $mapping['joinTable']['inverseJoinColumns'][0]['name'], // person_id $mapping['joinTable']['joinColumns'][0]['name'], // something_else_id @@ -165,7 +165,7 @@ class PersonMove ); $deleteSql = sprintf( - "DELETE FROM %s WHERE %s = %d", + "DELETE FROM %s WHERE %s = %d;", $tableName, $mapping['joinTable']['inverseJoinColumns'][0]['name'], // person_id $from->getId() @@ -196,7 +196,7 @@ class PersonMove } return [sprintf( - 'UPDATE %s SET %s WHERE %s', + 'UPDATE %s SET %s WHERE %s;', $tableName, implode(' ', $sets), implode(' AND ', $conditions) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php index 7ade542e0..31ec67a40 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php @@ -120,6 +120,7 @@ class PersonDuplicateController extends Controller $connection->beginTransaction(); foreach ($sqls as $sql) { + dump($sql); $connection->executeQuery($sql); } $connection->commit();