Skip to content

Log SQL errors when altering fields #3111

@spapas

Description

@spapas

Problem

I am trying to convert a column to a different type. The conversion doesn't work for some reason and I get a "Average mass kg" cannot be cast to numeric. when I click the save button. When I check the chrome tools I see that it issues a PATCH request to http://127.0.0.1:8000/api/db/v0/tables/2/columns/10/ with the following payload {"type":"numeric","type_options":{"precision":6,"scale":3},"display_options":null,"default":null}; the response is

[
    {
        "code": 4203,
        "message": "\"Average mass kg\" cannot be cast to numeric.",
        "field": null,
        "detail": null
    }
]

My understanding is that there's some SQL related exception that is caught and handled properly. However I don't see anything on my logs. The exception must be output somewhere (ideally on the logs) so we can debug the issue.

Proposed solution

Properly log the SQL errror.

Additional context

This is because of the big try-catch on https://github.com/centerofci/mathesar/blob/develop/mathesar/api/db/viewsets/columns.py#L110. The stacktrace should be printed on all cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions