top-think / top-think/think-orm

设置了软删除字段的类型,但是输出还是字符串

Open
#795 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
437
Forks
188
PR merge metrics
No merged PRs in 30d

Description

模型设置了软删除字段

protected function init(): void
    {
        // 模型初始化
        $this->setOption('deleteTime', 'del_time');
        $this->setOption('defaultSoftDelete', 0);
        $this->setOption('type', ['del_time'=>'int']);
    }

使用字段
$model->del_time
结果是字符串,导致之前写的判断是否被删除都变无效了。

看了之前版本的文档说软删除字段使用时间戳,新版本改成时间类型?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the model configuration with the del_time soft-delete field and inspect how the ORM applies field type casting when the field is accessed. Done means the configured type is respected and soft-delete checks no longer receive an unexpected string.

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
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.