From 6c86492352892b19ba1c8724b0dcec380a2d60d1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 22 Oct 2024 11:20:38 +0200 Subject: [PATCH] fix(entity): Fix mapping of old/sub-types to actually supported database types Signed-off-by: Joas Schilling --- lib/public/AppFramework/Db/Entity.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index cd15df134f1bd..0580d64e0f5e5 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -112,6 +112,15 @@ protected function setter(string $name, array $args): void { } switch ($type) { + case Types::BIGINT: + case Types::DECIMAL: + case Types::SMALLINT: + settype($args[0], Types::INTEGER); + break; + case Types::BINARY: + case Types::TEXT: + settype($args[0], Types::STRING); + break; case Types::TIME: case Types::DATE: case Types::DATETIME: @@ -263,6 +272,17 @@ public function getUpdatedFields(): array { * @since 7.0.0 */ protected function addType(string $fieldName, string $type): void { + if (in_array($type, ['bool', 'double', 'int', 'array', 'object'], true)) { + // Mapping legacy strings to the actual types + $type = match ($type) { + 'int' => Types::INTEGER, + 'bool' => Types::BOOLEAN, + 'double' => Types::FLOAT, + 'array', + 'object' => Types::STRING, + }; + } + $this->_fieldTypes[$fieldName] = $type; }