修复 find => force => save 这个流程下update_time 不更新的问题#852
Open
ichynul wants to merge 1 commit into
Open
Conversation
```php $user = User::find(1); $res = $user->force()->save(['name' => '小明' . time()]); //结果表中`update_time`不更新。 ``` 原因分析,find查询出表中的所有字段,包含`update_time`。 当调用->force()后,更新的时候不检查是否需要更新并unset()未改变字段。 把查询出来的`update_time`值原样写回去。 在`autoDateTime`方法中,判断当保存的数据中`update_time`字段空才会把它设置为当前时间
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.0 #852 +/- ##
=========================================
Coverage 51.98% 51.98%
- Complexity 3530 3531 +1
=========================================
Files 74 74
Lines 8314 8314
=========================================
Hits 4322 4322
Misses 3992 3992
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
原因分析,find查询出表中的所有字段,包含
update_time。当调用->force()后,更新的时候不检查是否需要更新并unset()未改变字段。
把查询出来的
update_time值原样写回去。在
autoDateTime方法中,判断当保存的数据中update_time字段空才会把它设置为当前时间