top-think / think-orm

Think ORM——the PHP Database&ORM Framework
Apache License 2.0
413 stars 171 forks source link

优化hasWhere方法 #596

Closed Hhh0121 closed 1 month ago

Hhh0121 commented 1 month ago

1.hasWhere和where方法同时使用,没有自动加别名 image image 2.对关联模型的软删除查询有问题,如果hasWhere闭包里写的有or查询会导致软删除查询限制无效 image image 3.where方法传入query类的时候,会清空替换掉前面的查询条件 image image 优化如下:增加默认查询条件下的字段别名,去除关联模型的软删除查询(像withjoin和join都不支持都对关联模型的软删除查询),hasWhere函数内where增加闭包(支持和where方法同时使用)

codecov-commenter commented 1 month ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Project coverage is 12.26%. Comparing base (e35f497) to head (454099a). Report is 34 commits behind head on 3.0.

Files Patch % Lines
src/model/relation/BelongsTo.php 0.00% 4 Missing :warning:
src/model/relation/HasMany.php 0.00% 4 Missing :warning:
src/model/relation/HasManyThrough.php 0.00% 4 Missing :warning:
src/model/relation/HasOne.php 0.00% 4 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## 3.0 #596 +/- ## ============================================ + Coverage 12.24% 12.26% +0.01% - Complexity 2965 2980 +15 ============================================ Files 64 64 Lines 7129 7150 +21 ============================================ + Hits 873 877 +4 - Misses 6256 6273 +17 ``` | [Flag](https://app.codecov.io/gh/top-think/think-orm/pull/596/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=top-think) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/top-think/think-orm/pull/596/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=top-think) | `12.26% <0.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=top-think#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Hhh0121 commented 1 month ago

512 #294

liu21st commented 1 month ago

其它的能理解 但不需要软删除这个还需要讨论下

Hhh0121 commented 1 month ago

其它的能理解 但不需要软删除这个还需要讨论下

看下第二条的代码和打印的sql,现在无法对关联模型的软删除支持(像withjoin也是不行的)

liu21st commented 1 month ago

其它的能理解 但不需要软删除这个还需要讨论下

看下第二条的代码和打印的sql,现在无法对关联模型的软删除支持(像withjoin也是不行的)

我的理解是不是软删除目前支持有点问题 但不代表不能支持 而且从需求来说 软删除也是有需求的

Hhh0121 commented 1 month ago

其它的能理解 但不需要软删除这个还需要讨论下

看下第二条的代码和打印的sql,现在无法对关联模型的软删除支持(像withjoin也是不行的)

我的理解是不是软删除目前支持有点问题 但不代表不能支持 而且从需求来说 软删除也是有需求的

是的,现在不行,如果想支持关联模型的软删除,改动比较大,建议把用到join的地方都改一下

liu21st commented 1 month ago

我目前测试下来 在进行了你提交的相关修正后 软删除看起来是没问题的

Hhh0121 commented 1 month ago

我目前测试下来 在进行了你提交的相关修正后 软删除看起来是没问题的

现在如果只是单用hasWhere是没问题的,如果和其他where同时用,就不行了。 所以我建议先去掉,后面底层优化支持一下

liu21st commented 1 month ago

我测试的就是haswhere和where一起使用的情况