Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show typecast error while changing data type in preview mode #3566

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mathesar/api/db/viewsets/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.mixins import CreateModelMixin, ListModelMixin, RetrieveModelMixin
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from sqlalchemy.exc import DataError, IntegrityError, ProgrammingError
from sqlalchemy.exc import DataError, IntegrityError, ProgrammingError, InternalError

from db.types.exceptions import UnsupportedTypeException
from db.columns.exceptions import NotNullError, ForeignKeyError, TypeMismatchError, UniqueValueError, ExclusionError, ColumnMappingsNotFound
Expand Down Expand Up @@ -154,16 +154,16 @@
table_data = TableSerializer(table, context={"request": request}).data
try:
preview_records = table.get_preview(columns)
except (DataError, IntegrityError) as e:
except (DataError, IntegrityError, InternalError) as e:
if type(e.orig) is InvalidTextRepresentation or type(e.orig) is CheckViolation:
raise database_api_exceptions.InvalidTypeCastAPIException(
e,

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
status_code=status.HTTP_400_BAD_REQUEST,
field='columns'
)
else:
raise database_base_api_exceptions.IntegrityAPIException(
e,

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
status_code=status.HTTP_400_BAD_REQUEST,
field='columns'
)
Expand Down
Loading