From b738ffe7db89e2d7bcc0dd4e6454a894a4b3b8d5 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 20 Dec 2013 18:34:34 +0200 Subject: [PATCH] fix problem with custom type for doctrine dbal --- .../Espo/Core/Utils/Database/FieldTypes/Password.php | 5 +++++ application/Espo/Core/Utils/Database/Schema.php | 2 +- .../dbal/lib/Doctrine/DBAL/Schema/Comparator.php | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/Utils/Database/FieldTypes/Password.php b/application/Espo/Core/Utils/Database/FieldTypes/Password.php index b9bf67d5b1..04748737d4 100644 --- a/application/Espo/Core/Utils/Database/FieldTypes/Password.php +++ b/application/Espo/Core/Utils/Database/FieldTypes/Password.php @@ -14,6 +14,11 @@ class Password extends Type return self::PASSWORD; } + public static function getDbTypeName() + { + return 'VARCHAR'; + } + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) { return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); diff --git a/application/Espo/Core/Utils/Database/Schema.php b/application/Espo/Core/Utils/Database/Schema.php index 885b8c6451..b87eb63ad5 100644 --- a/application/Espo/Core/Utils/Database/Schema.php +++ b/application/Espo/Core/Utils/Database/Schema.php @@ -137,7 +137,7 @@ class Schema } } - return $result; + return (bool) $result; } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php index 839108f4e8..ae2e16c65a 100644 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php @@ -360,7 +360,16 @@ class Comparator { $changedProperties = array(); if ( $column1->getType() != $column2->getType() ) { - $changedProperties[] = 'type'; + + //espo: fix problem with executing query for custom types + $column1DbTypeName = method_exists($column1->getType(), 'getDbTypeName') ? $column1->getType()->getDbTypeName() : $column1->getType()->getName(); + $column2DbTypeName = method_exists($column2->getType(), 'getDbTypeName') ? $column2->getType()->getDbTypeName() : $column2->getType()->getName(); + + if (strtolower($column1DbTypeName) != strtolower($column2DbTypeName)) { + $changedProperties[] = 'type'; + } + //$changedProperties[] = 'type'; + //END: espo } if ($column1->getNotnull() != $column2->getNotnull()) {