Skip to content

SoftDeleteQueryBehavior being ignored #5

Open
@DiogoAbdalla

Description

@DiogoAbdalla

Hey, Ive set softdelete behavior in an ActiveRecord model with the following config:

            TimestampBehavior::className(),
            'softDeleteBehavior' => [
                'class'                     => SoftDeleteBehavior::className(),
                'softDeleteAttributeValues' => [
                    'deleted_at' => new Expression('UNIX_TIMESTAMP()')
                ],
                'replaceRegularDelete'      => true
            ],

Its working: when I delete, "detelet_at" is set with the unix timestamp.

Now, to retrieve without the deleted ones, Ive set the query like this:

class UserQuery extends ActiveQuery
{

    public function behaviors()
    {
        return [
            'softDelete' => [
                'class' => SoftDeleteQueryBehavior::className(),
                'deletedCondition'    => [
                    'deleted_at' => new Expression('IS NOT NULL'),
                ],
                'notDeletedCondition' => [
                    'deleted_at' => new Expression('IS NULL'),
                ],
            ],
        ];
    }
}

Its being completely ignored, the deleted records are returned normally on any query

Im not sure its a bug, sorry if it inst. But everything seems right and I dont know what could be wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions