Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改进模型自动创建时间和更新时间 #525

Merged
merged 11 commits into from
Jun 6, 2023

Conversation

NHZEX
Copy link
Member

@NHZEX NHZEX commented May 26, 2023

  • 允许模型输入时间覆盖自动生成行为
  • 改进模型的自动时间测试

@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.81 ⚠️

Comparison is base (fc9dd0f) 65.20% compared to head (687f6a8) 64.39%.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.1     #525      +/-   ##
============================================
- Coverage     65.20%   64.39%   -0.81%     
- Complexity    10987    10999      +12     
============================================
  Files           881      881              
  Lines         30050    30055       +5     
============================================
- Hits          19594    19355     -239     
- Misses        10456    10700     +244     
Impacted Files Coverage Δ
src/Components/pgsql/src/Model/PgModel.php 88.00% <100.00%> (+1.63%) ⬆️
src/Model/Model.php 88.00% <100.00%> (+0.07%) ⬆️

... and 25 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@NHZEX NHZEX force-pushed the dev/model-auto-time branch from e0d2232 to b2c4ad7 Compare June 2, 2023 08:13
@NHZEX NHZEX force-pushed the dev/model-auto-time branch from e3f525f to fbf52f9 Compare June 3, 2023 07:59
@Yurunsoft Yurunsoft added 2.1 optimization Optimization labels Jun 4, 2023
@Yurunsoft Yurunsoft changed the title 模型自动时间的改进 改进模型自动创建时间和更新时间 Jun 4, 2023
@@ -1028,6 +1030,7 @@ private static function parseSaveData($data, string $type, ?self $object = null)
}
$incrUpdate = $meta->isIncrUpdate();
$ids = $meta->getIds();
$microTime = microtime(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

创建时间和更新时间字段不一定存在,要不要把下面用到的的 $microTime 改成 $microTime ??=microtime(true)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看看这个改动

src/Model/Model.php Outdated Show resolved Hide resolved
@Yurunsoft Yurunsoft merged commit 47a8130 into imiphp:2.1 Jun 6, 2023
NHZEX added a commit to NHZEX/imi that referenced this pull request Oct 18, 2023
* update 模型自动时间支持传入覆盖

* 调整

* 兼容pg更改

* 修复更新时无法写入更新时间

* 修复测试

* 修复测试

* 移除多余的类型转换

* 改进pg的测试

* 修复格式

* 调整时间赋值时机

* 改进格式
@NHZEX NHZEX deleted the dev/model-auto-time branch October 23, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants