fastapi-amis-admin icon indicating copy to clipboard operation
fastapi-amis-admin copied to clipboard

JSONB, post raise exception

Open mmmcorpsvit opened this issue 1 month ago • 0 comments

class Lot(PkModelMixin, CreateTimeModelMixin, UpdateTimeModelMixin, table=True):
    data: dict = AdminField(title='Data', sa_column=Column("data", JSONB, nullable=True), default=None, )

try post correct JSON

{"a": "1"}

raise exception

{
    "status": 422,
    "msg": "Request parameter validation exception",
    "data": null,
    "code": null,
    "body": {
        "updated": "2024-05-17T18:01:21",
        "created": "2024-05-02T18:01:25",
        "vin": "2C3CDXHG2NH169812",
        "sale_datetime": "2024-05-15T18:00:35",
        "item": 45345,
        "number": 45345,
        "year": 2020,
        "active": false,
        "odometer": 0,
        "data": "{\"a\": \"1\"}",
        "status_id": 3,
        "color_id": 956,
        "lot_model_id": 1,
        "location_id": 9938,
        "has_keys": 2
    },
    "errors": [
        {
            "type": "dict_type",
            "loc": [
                "body",
                "data"
            ],
            "msg": "Input should be a valid dictionary",
            "input": "{\"a\": \"1\"}"
        }
    ]
}

how fix?

mmmcorpsvit avatar May 07 '24 18:05 mmmcorpsvit