diff --git a/src/Mapper/Dbal/DbalMapper.php b/src/Mapper/Dbal/DbalMapper.php index 76fe87fd..1c9dfc20 100644 --- a/src/Mapper/Dbal/DbalMapper.php +++ b/src/Mapper/Dbal/DbalMapper.php @@ -353,7 +353,10 @@ public function persist(IEntity $entity): void } else { $primary = []; - $id = (array) $entity->getPersistedId(); + $id = $entity->getPersistedId(); + if (!is_array($id)) { + $id = [$id]; + } foreach ($entity->getMetadata()->getPrimaryKey() as $key) { $primary[$key] = array_shift($id); } @@ -458,7 +461,10 @@ protected function processMySQLAutoupdate(IEntity $entity, array $args): void $conventions = $this->getConventions(); - $id = (array) $entity->getPersistedId(); + $id = $entity->getPersistedId(); + if (!is_array($id)) { + $id = [$id]; + } $primary = []; foreach ($entity->getMetadata()->getPrimaryKey() as $key) { $primary[$key] = array_shift($id); @@ -487,7 +493,10 @@ public function remove(IEntity $entity): void $conventions = $this->getConventions(); $primary = []; - $id = (array) $entity->getPersistedId(); + $id = $entity->getPersistedId(); + if (!is_array($id)) { + $id = [$id]; + } foreach ($entity->getMetadata()->getPrimaryKey() as $key) { $key = $conventions->convertEntityToStorageKey($key); $primary[$key] = array_shift($id); diff --git a/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPk.sql b/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPk.sql index 8ffa6c23..c142dfda 100644 --- a/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPk.sql +++ b/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPk.sql @@ -2,5 +2,5 @@ START TRANSACTION; INSERT INTO "logs" ("date", "count") VALUES ('2022-03-06 03:03:03.000000'::timestamptz, 3); COMMIT; START TRANSACTION; -UPDATE "logs" SET "count" = 5 WHERE "date" = '2022-03-06 03:03:03.000000'; +UPDATE "logs" SET "count" = 5 WHERE "date" = '2022-03-06 03:03:03.000000'::timestamptz; COMMIT; diff --git a/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPkUpdate.sql b/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPkUpdate.sql index 12905cd6..556acaa1 100644 --- a/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPkUpdate.sql +++ b/tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPkUpdate.sql @@ -4,6 +4,6 @@ COMMIT; SELECT "time_series".* FROM "time_series" AS "time_series" WHERE (("time_series"."date" = '2022-03-06 03:03:03.000000'::timestamptz)); SELECT "time_series".* FROM "time_series" AS "time_series" WHERE (("time_series"."date" = '2022-03-06 03:03:03.000000'::timestamptz)); START TRANSACTION; -UPDATE "time_series" SET "value" = 5 WHERE "date" = '2022-03-06 04:03:03.000000'; +UPDATE "time_series" SET "value" = 5 WHERE "date" = '2022-03-06 03:03:03.000000'::timestamptz; COMMIT; SELECT "time_series".* FROM "time_series" AS "time_series" WHERE (("time_series"."date" = '2022-03-06 03:03:03.000000'::timestamptz));