top-think / top-think/think-orm
软删除查询拼接字段值错误
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
输出的SQL语句,delete_time 应该是个 int 才对,现在变成了 string,会导致索引问题
SELECT * FROM `admin` WHERE ( `id` = 1 ) AND `admin`.`delete_time` = '0' LIMIT 1
我的软删除模型定义
<?php
namespace app\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* @method $this fetchSql(bool $fetch = true) 获取查询语句,返回 string
* @method $this buildSql(bool $sub = true) 构建子查询语句,返回 string
**/
class BaseModel extends Model
{
// 引入软删除功能
use SoftDelete;
protected function init(): void
{
parent::init();
$this->setOptions([
'defaultSoftDelete' => 0,
]);
}
}
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 by tracing the SoftDelete behavior and Model query construction using the BaseModel definition and generated SQL shown in the issue. Reproduce the query and verify that delete_time is emitted as the integer 0 rather than the string '0', then confirm the resulting SQL remains compatible with the intended index usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100