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

优化hasWhere方法 #596

Closed
wants to merge 1 commit into from
Closed

优化hasWhere方法 #596

wants to merge 1 commit into from

Conversation

Hhh0121
Copy link
Contributor

@Hhh0121 Hhh0121 commented Jul 30, 2024

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

@codecov-commenter
Copy link

⚠️ 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 ⚠️
src/model/relation/HasMany.php 0.00% 4 Missing ⚠️
src/model/relation/HasManyThrough.php 0.00% 4 Missing ⚠️
src/model/relation/HasOne.php 0.00% 4 Missing ⚠️

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

Additional details and impacted files
@@             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 Coverage Δ
unittests 12.26% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@big-dream big-dream linked an issue Jul 30, 2024 that may be closed by this pull request
@Hhh0121
Copy link
Contributor Author

Hhh0121 commented Jul 30, 2024

#512 #294

@big-dream big-dream linked an issue Jul 30, 2024 that may be closed by this pull request
@liu21st
Copy link
Member

liu21st commented Jul 31, 2024

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

@Hhh0121
Copy link
Contributor Author

Hhh0121 commented Jul 31, 2024

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

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

@liu21st
Copy link
Member

liu21st commented Jul 31, 2024

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

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

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

@Hhh0121
Copy link
Contributor Author

Hhh0121 commented Jul 31, 2024

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

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

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

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

@liu21st
Copy link
Member

liu21st commented Jul 31, 2024

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

@Hhh0121
Copy link
Contributor Author

Hhh0121 commented Aug 1, 2024

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

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

@liu21st
Copy link
Member

liu21st commented Aug 1, 2024

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

@liu21st liu21st closed this Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hasWhere 未自动字段加上表别名 一对一关联hasWhere和where同时使用bug
3 participants