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)
785
785
}
786
786
}
787
787
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
+
788
806
/**
789
807
* Update existing object
790
808
*
@@ -798,7 +816,9 @@ protected function updateObject(\Magento\Framework\Model\AbstractModel $object)
798
816
$ connection = $ this ->getConnection ();
799
817
$ tableDescription = $ connection ->describeTable ($ this ->getMainTable ());
800
818
$ 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 );
802
822
803
823
/**
804
824
* Not auto increment primary key support
Original file line number Diff line number Diff line change @@ -496,7 +496,7 @@ public function testPrepareDataForUpdate()
496
496
->with (
497
497
'tableName ' ,
498
498
$ newData ,
499
- 'idFieldName=0 '
499
+ 'idFieldName '
500
500
);
501
501
$ select = $ this ->getMockBuilder (\Magento \Framework \DB \Select::class)
502
502
->disableOriginalConstructor ()
You can’t perform that action at this time.
0 commit comments