Skip to content

Commit

Permalink
fix(entity): Fix mapping of old/sub-types to actually supported datab…
Browse files Browse the repository at this point in the history
…ase types

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 22, 2024
1 parent 582af10 commit 6c86492
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/public/AppFramework/Db/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,

Check failure on line 278 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:278:5: TypeDoesNotContainType: Type never for $type is never =string(int) (see https://psalm.dev/056)

Check failure on line 278 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:278:5: TypeDoesNotContainType: Type never for $type is never =string(int) (see https://psalm.dev/056)
'bool' => Types::BOOLEAN,

Check failure on line 279 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:279:5: TypeDoesNotContainType: Type never for $type is never =string(bool) (see https://psalm.dev/056)

Check failure on line 279 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:279:5: TypeDoesNotContainType: Type never for $type is never =string(bool) (see https://psalm.dev/056)
'double' => Types::FLOAT,

Check failure on line 280 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:280:5: TypeDoesNotContainType: Type never for $type is never =string(double) (see https://psalm.dev/056)

Check failure on line 280 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:280:5: TypeDoesNotContainType: Type never for $type is never =string(double) (see https://psalm.dev/056)
'array',

Check failure on line 281 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:281:5: TypeDoesNotContainType: Type never for $type is never =string(array) (see https://psalm.dev/056)

Check failure on line 281 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:281:5: TypeDoesNotContainType: Type never for $type is never =string(object) (see https://psalm.dev/056)

Check failure on line 281 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:281:5: TypeDoesNotContainType: Type never for $type is never =string(array) (see https://psalm.dev/056)

Check failure on line 281 in lib/public/AppFramework/Db/Entity.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

TypeDoesNotContainType

lib/public/AppFramework/Db/Entity.php:281:5: TypeDoesNotContainType: Type never for $type is never =string(object) (see https://psalm.dev/056)
'object' => Types::STRING,
};
}

$this->_fieldTypes[$fieldName] = $type;
}

Expand Down

0 comments on commit 6c86492

Please sign in to comment.