File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
lib/internal/Magento/Framework/Model
Test/Unit/ResourceModel/Db Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -785,6 +785,24 @@ protected function saveNewObject(\Magento\Framework\Model\AbstractModel $object)
785785 }
786786 }
787787
788+ /**
789+ * Check in column value should be quoted
790+ *
791+ * Based on column description
792+ *
793+ * @param array $columnDescription
794+ * @return bool
795+ */
796+ private function isNeedToQuoteValue (array $ columnDescription ): bool
797+ {
798+ $ result = true ;
799+ if (!empty ($ columnDescription ['DATA_TYPE ' ])
800+ && in_array ($ columnDescription ['DATA_TYPE ' ], ['smallint ' , 'int ' ])) {
801+ $ result = false ;
802+ }
803+ return $ result ;
804+ }
805+
788806 /**
789807 * Update existing object
790808 *
@@ -798,7 +816,9 @@ protected function updateObject(\Magento\Framework\Model\AbstractModel $object)
798816 $ connection = $ this ->getConnection ();
799817 $ tableDescription = $ connection ->describeTable ($ this ->getMainTable ());
800818 $ preparedValue = $ connection ->prepareColumnValue ($ tableDescription [$ this ->getIdFieldName ()], $ object ->getId ());
801- $ condition = $ this ->getIdFieldName () . '= ' . $ preparedValue ;
819+ $ condition = (!$ this ->isNeedToQuoteValue ($ tableDescription [$ this ->getIdFieldName ()]))
820+ ? $ this ->getIdFieldName () . '= ' . $ preparedValue
821+ : $ connection ->quoteInto ($ this ->getIdFieldName () . '=? ' , $ preparedValue );
802822
803823 /**
804824 * Not auto increment primary key support
Original file line number Diff line number Diff line change @@ -496,7 +496,7 @@ public function testPrepareDataForUpdate()
496496 ->with (
497497 'tableName ' ,
498498 $ newData ,
499- 'idFieldName=0 '
499+ 'idFieldName '
500500 );
501501 $ select = $ this ->getMockBuilder (\Magento \Framework \DB \Select::class)
502502 ->disableOriginalConstructor ()
You can’t perform that action at this time.
0 commit comments