Skip to content

Commit d79b8a6

Browse files
author
Oleksandr Iegorov
committed
MC-19791: Poor performance on sales order update - string to integer
1 parent eabed8b commit d79b8a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,11 @@ protected function saveNewObject(\Magento\Framework\Model\AbstractModel $object)
792792
* @param array $columnDescription
793793
* @return bool
794794
*/
795-
private function isNeedToQuoteValue(array $columnDescription): bool
795+
private function isNumericValue(array $columnDescription): bool
796796
{
797797
$result = true;
798798
if (!empty($columnDescription['DATA_TYPE'])
799-
&& in_array($columnDescription['DATA_TYPE'], ['smallint', 'int'])) {
799+
&& in_array($columnDescription['DATA_TYPE'], ['tinyint', 'smallint', 'mediumint', 'int', 'bigint'])) {
800800
$result = false;
801801
}
802802
return $result;
@@ -814,8 +814,8 @@ protected function updateObject(\Magento\Framework\Model\AbstractModel $object)
814814
$connection = $this->getConnection();
815815
$tableDescription = $connection->describeTable($this->getMainTable());
816816
$preparedValue = $connection->prepareColumnValue($tableDescription[$this->getIdFieldName()], $object->getId());
817-
$condition = (!$this->isNeedToQuoteValue($tableDescription[$this->getIdFieldName()]))
818-
? $this->getIdFieldName() . '=' . $preparedValue
817+
$condition = (!$this->isNumericValue($tableDescription[$this->getIdFieldName()]))
818+
? sprintf('%s=%d', $this->getIdFieldName(), $preparedValue)
819819
: $connection->quoteInto($this->getIdFieldName() . '=?', $preparedValue);
820820

821821
/**

0 commit comments

Comments
 (0)