@@ -208,7 +208,8 @@ abstract class BaseModel
208208 protected bool $ updateOnlyChanged = true ;
209209
210210 /**
211- * Rules used to validate data in insert(), update(), and save() methods.
211+ * Rules used to validate data in insert(), update(), save(),
212+ * insertBatch(), and updateBatch() methods.
212213 *
213214 * The array must match the format of data passed to the Validation
214215 * library.
@@ -909,7 +910,7 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
909910
910911 if (is_array ($ set )) {
911912 foreach ($ set as &$ row ) {
912- $ row = $ this ->transformDataRowToArray ($ row );
913+ $ row = $ this ->transformDataToArray ($ row, ' insert ' );
913914
914915 // Validate every row.
915916 if (! $ this ->skipValidation && ! $ this ->validate ($ row )) {
@@ -1036,7 +1037,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
10361037 {
10371038 if (is_array ($ set )) {
10381039 foreach ($ set as &$ row ) {
1039- $ row = $ this ->transformDataRowToArray ($ row );
1040+ $ row = $ this ->transformDataToArray ($ row, ' update ' );
10401041
10411042 // Validate data before saving.
10421043 if (! $ this ->skipValidation && ! $ this ->validate ($ row )) {
@@ -1667,52 +1668,6 @@ protected function trigger(string $event, array $eventData)
16671668 return $ eventData ;
16681669 }
16691670
1670- /**
1671- * If the model is using casts, this will convert the data
1672- * in $row according to the rules defined in `$casts`.
1673- *
1674- * @param object|row_array|null $row Row data
1675- *
1676- * @return object|row_array|null Converted row data
1677- *
1678- * @used-by insertBatch()
1679- * @used-by updateBatch()
1680- *
1681- * @throws ReflectionException
1682- * @deprecated Since 4.6.4, temporary solution - will be removed in 4.7
1683- */
1684- protected function transformDataRowToArray (array |object |null $ row ): array |object |null
1685- {
1686- // If casts are used, convert the data first
1687- if ($ this ->useCasts ()) {
1688- if (is_array ($ row )) {
1689- $ row = $ this ->converter ->toDataSource ($ row );
1690- } elseif ($ row instanceof stdClass) {
1691- $ row = (array ) $ row ;
1692- $ row = $ this ->converter ->toDataSource ($ row );
1693- } elseif ($ row instanceof Entity) {
1694- $ row = $ this ->converter ->extract ($ row );
1695- } elseif (is_object ($ row )) {
1696- $ row = $ this ->converter ->extract ($ row );
1697- }
1698- } elseif (is_object ($ row ) && ! $ row instanceof stdClass) {
1699- // If $row is using a custom class with public or protected
1700- // properties representing the collection elements, we need to grab
1701- // them as an array.
1702- $ row = $ this ->objectToArray ($ row , false , true );
1703- }
1704-
1705- // If it's still a stdClass, go ahead and convert to
1706- // an array so doProtectFields and other model methods
1707- // don't have to do special checks.
1708- if (is_object ($ row )) {
1709- $ row = (array ) $ row ;
1710- }
1711-
1712- // Convert any Time instances to appropriate $dateFormat
1713- return $ this ->timeToString ($ row );
1714- }
1715-
17161671 /**
17171672 * Sets the return type of the results to be as an associative array.
17181673 *
@@ -1830,7 +1785,9 @@ protected function objectToRawArray($object, bool $onlyChanged = true, bool $rec
18301785 * @throws ReflectionException
18311786 *
18321787 * @used-by insert()
1788+ * @used-by insertBatch()
18331789 * @used-by update()
1790+ * @used-by updateBatch()
18341791 */
18351792 protected function transformDataToArray ($ row , string $ type ): array
18361793 {
0 commit comments