Skip to content

delete will throw an exception if invoked on a non existing record. #355

Closed
@wiseaidev

Description

@wiseaidev

Code to reproduce the issue:

from typing import Optional, Any

from fastapi import FastAPI

from pydantic import BaseModel, Field as PydanticField, EmailStr
import datetime

from aredis_om import (
    Field,
    HashModel,
    Migrator,
    get_redis_connection
)

redis_conn = get_redis_connection(
    url=f"redis://localhost:6379",
    decode_responses=True
)

class User(HashModel):
    first_name: Optional[str] = Field(index=True)
    last_name: Optional[str] = Field(index=True)
    email: EmailStr = Field(index=True)
    password: str = Field(index=True)
    created_on: Optional[datetime.datetime] = Field(default_factory=datetime.datetime.now)

    class Meta:
        database = redis_conn

router = FastAPI(title=__name__)

@router.on_event("startup")
async def startup():
    await Migrator().run()
    user2 = await User(email="yo@wiseai.dev", password="P@ssW0rD").save()
    await User.find(User.email=="yo@wiseai.dev").delete()
    await User.find(User.email=="yo@wiseai.dev").delete()

Output:

raise response from None
aioredis.exceptions.ResponseError: wrong number of arguments for 'del' command

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions