top-think / top-think/think-orm
升级后查询范围置后了,如果之前没写闭包的or查询会出现问题
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
升级后查询范围置后了,会之前没写闭包的or查询出现问题
比如:
User::scope('zuhu')->whereOr([['name','like','%'.$keyword.'%'],['email','like','%'.$keyword.'%'],['mobile','like','%'.$keyword.'%']])->select();
最终的语句是
SELECT * FROM user WHERE ( name LIKE '%12345678901%' OR email LIKE '%12345678901%' OR mobile LIKE '%12345678901%' AND zuhu_id = '1' ),
以前的语句是
SELECT * FROM user WHERE zuhu_id = '1' AND ( name LIKE '%12345678901%' OR email LIKE '%12345678901%' OR mobile LIKE '%12345678901%')
为啥要把scope条件置后呢?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ORM query-building path used by scope('zuhu'), whereOr(), and select(), then reproduce the two SQL forms shown in the issue. Trace why the scope predicate is placed inside the OR expression after the upgrade. Done means the scope condition is grouped with the intended precedence and the reported query produces the expected SQL; no files or tests are named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100