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

修复查询构建器 join 方法传入 $where 参数的报错 #529

Merged
merged 7 commits into from
Jun 2, 2023

Conversation

wiilruo
Copy link
Contributor

@wiilruo wiilruo commented May 31, 2023

join操作时,如果有where对象,原本使用toString获取拼接语句是错的,因修改为toStringWithoutLogic,同时与sql语句拼接时,缺少and

Copy link
Member

@Yurunsoft Yurunsoft left a comment

Choose a reason for hiding this comment

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

需要在 tests/unit/Component/Tests/Db/QueryCurdBaseTest.php 增加一个针对 join 的测试用例

@@ -186,7 +186,7 @@ public function toString(IQuery $query): string
$result = $this->type . ' join ' . $this->table->toString($query) . ' on ' . $query->fieldQuote($this->left ?? '') . $this->operation . $query->fieldQuote($this->right ?? '');
if ($this->where instanceof IBaseWhere)
{
$result .= ' ' . $this->where->toString($query);
$result .= ' and ' . $this->where->toStringWithoutLogic($query);
Copy link
Member

Choose a reason for hiding this comment

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

and 可以用 $this->where->getLogicalOperator() 代替

@Yurunsoft Yurunsoft added bug Something isn't working 2.1 labels May 31, 2023
@Yurunsoft Yurunsoft changed the title 修复Db的join操作中,使用where时的 where语句获取函数错误和语句拼接缺少and错误 修复查询构建器 join 方法传入 $where 参数的报错 May 31, 2023
@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

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

Comparison is base (1b89b5c) 64.33% compared to head (0500578) 63.90%.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.1     #529      +/-   ##
============================================
- Coverage     64.33%   63.90%   -0.43%     
- Complexity    10986    10987       +1     
============================================
  Files           881      881              
  Lines         30048    30044       -4     
============================================
- Hits          19332    19201     -131     
- Misses        10716    10843     +127     
Impacted Files Coverage Δ
src/Db/Query/Join.php 41.17% <100.00%> (+3.92%) ⬆️

... and 21 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.

@Yurunsoft Yurunsoft merged commit 7c2dc2a into imiphp:2.1 Jun 2, 2023
NHZEX pushed a commit to NHZEX/imi that referenced this pull request Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.1 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants