DBAL: compare text length

This commit is contained in:
Taras Machyshyn
2018-12-20 17:10:42 +02:00
parent 5d47a987f4
commit 65368519c7
2 changed files with 11 additions and 3 deletions
@@ -28,12 +28,11 @@
************************************************************************/
namespace Espo\Core\Utils\Database\DBAL\Schema;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Column;
class Comparator extends \Doctrine\DBAL\Schema\Comparator
{
public function diffColumn(Column $column1, Column $column2)
{
$changedProperties = array();
@@ -80,6 +79,15 @@ class Comparator extends \Doctrine\DBAL\Schema\Comparator
}
}
if ($column1->getType() instanceof \Doctrine\DBAL\Types\TextType) {
$length1 = $column1->getLength() ?: 16777215/* mediumtext length*/;
$length2 = $column2->getLength() ?: 16777215;
if ($length2 > $length1) {
$changedProperties[] = 'length';
}
}
if ($column1->getType() instanceof \Doctrine\DBAL\Types\DecimalType) {
if (($column1->getPrecision()?:10) != ($column2->getPrecision()?:10)) {
$changedProperties[] = 'precision';
@@ -47,7 +47,7 @@ return [
],
'data' => [
'type' => 'text',
'dbType' => 'longtext',
'len' => 16777216,
]
]
],