We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Columns re-ordered after type change
## Reproduce

1. "New Table" > "Import Data" > "Copy and Paste Text"

1. Paste the following data and proceed to create and view the table (by clicking "Continue" and then "Finish Import").

    ```
    id,a,b
    1,100,200
    2,101,201
    ```

1. Click on the column header for column `a` and change the type from "Number" to "Text", clicking "Save".

1. Expect columns to be ordered `id`, `a`, `b`.

1. Once I did this and observed the columns to be ordered `a`, `id`, `b`. Another time. I observed the columns to be ordered `id`, `b`, `a`. I'm not sure what affects the ordering of the columns, but the order seems to remain consistent (even if incorrect) after the type-change operation.

## Implementation
The backend should make sure that the column list in the API should always be ordered by suitable `index`.

## Additional details

- The front end displays the columns in the order it receives them from the columns API. In this case the API is returning the columns out-of-order, which is why I've marked this as a backend bug.
- A while back, we had a [discussion about whether the user should be able to re-order columns](https://github.com/centerofci/mathesar/discussions/803) in which we decided _not_ to support re-ordering columns, at least for now.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mathesar/api/db/viewsets/columns.py`
Content:
```
1 import warnings
2 from psycopg2.errors import DuplicateColumn
3 from rest_framework import status, viewsets
4 from rest_framework.exceptions import NotFound
5 from rest_framework.response import Response
6 from sqlalchemy.exc import ProgrammingError
7 
8 from mathesar.api.exceptions.database_exceptions import (
9     exceptions as database_api_exceptions,
10     base_exceptions as database_base_api_exceptions,
11 )
12 from mathesar.api.exceptions.generic_exceptions import base_exceptions as base_api_exceptions
13 from db.columns.exceptions import (
14     DynamicDefaultWarning, InvalidDefaultError, InvalidTypeOptionError, InvalidTypeError,
15 )
16 from db.columns.operations.select import get_column_attnum_from_name
17 from db.types.exceptions import InvalidTypeParameters
18 from db.records.exceptions import UndefinedFunction
19 from mathesar.api.pagination import DefaultLimitOffsetPagination
20 from mathesar.api.serializers.columns import ColumnSerializer
21 from mathesar.api.utils import get_table_or_404
22 from mathesar.models import Column
23 
24 
25 class ColumnViewSet(viewsets.ModelViewSet):
26     serializer_class = ColumnSerializer
27     pagination_class = DefaultLimitOffsetPagination
28 
29     def get_queryset(self):
30         return Column.objects.filter(table=self.kwargs['table_pk'])
31 
32     def create(self, request, table_pk=None):
33         table = get_table_or_404(table_pk)
34         # We only support adding a single column through the API.
35         serializer = ColumnSerializer(data=request.data, context={'request': request})
36         serializer.is_valid(raise_exception=True)
37         type_options = request.data.get('type_options', None)
38         if type_options is not None:
39             scale = type_options.get('scale', None)
40             precision = type_options.get('precision', None)
41             if scale is not None and precision is None:
42                 request.data['type_options']['precision'] = 1000
43         if 'source_column' in serializer.validated_data:
44             column = table.duplicate_column(
45                 serializer.validated_data['source_column'],
46                 serializer.validated_data['copy_source_data'],
47                 serializer.validated_data['copy_source_constraints'],
48                 serializer.validated_data.get('name'),
49             )
50         else:
51             try:
52                 # TODO Refactor add_column to user serializer validated date instead of request data
53                 column = table.add_column(request.data)
54             except ProgrammingError as e:
55                 if type(e.orig) == DuplicateColumn:
56                     name = request.data['name']
57                     raise database_api_exceptions.DuplicateTableAPIException(
58                         e,
59                         message=f'Column {name} already exists',
60                         field='name',
61                         status_code=status.HTTP_400_BAD_REQUEST
62                     )
63                 else:
64                     raise database_base_api_exceptions.ProgrammingAPIException(e)
65             except TypeError as e:
66                 raise base_api_exceptions.TypeErrorAPIException(
67                     e,
68                     message="Unknown type_option passed",
69                     status_code=status.HTTP_400_BAD_REQUEST
70                 )
71             except InvalidDefaultError as e:
72                 raise database_api_exceptions.InvalidDefaultAPIException(
73                     e,
74                     message=f'default "{request.data["default"]}" is invalid for type {request.data["type"]}',
75                     status_code=status.HTTP_400_BAD_REQUEST
76                 )
77             except (InvalidTypeOptionError, InvalidTypeParameters) as e:
78                 type_options = request.data.get('type_options', '')
79                 raise database_api_exceptions.InvalidTypeOptionAPIException(
80                     e,
81                     message=f'parameter dict {type_options} is invalid for type {request.data["type"]}',
82                     field="type_options",
83                     status_code=status.HTTP_400_BAD_REQUEST
84                 )
85             except InvalidTypeError as e:
86                 raise database_api_exceptions.InvalidTypeCastAPIException(
87                     e,
88                     message='This type casting is invalid.',
89                     status_code=status.HTTP_400_BAD_REQUEST
90                 )
91         dj_column = Column(
92             table=table,
93             attnum=get_column_attnum_from_name(table.oid, column.name, table.schema._sa_engine),
94             **serializer.validated_model_fields
95         )
96         dj_column.save()
97         out_serializer = ColumnSerializer(dj_column)
98         return Response(out_serializer.data, status=status.HTTP_201_CREATED)
99 
100     def partial_update(self, request, pk=None, table_pk=None):
101         column_instance = self.get_object()
102         table = column_instance.table
103         serializer = ColumnSerializer(instance=column_instance, data=request.data, partial=True)
104         serializer.is_valid(raise_exception=True)
105         with warnings.catch_warnings():
106             warnings.filterwarnings("error", category=DynamicDefaultWarning)
107             try:
108                 table.alter_column(column_instance._sa_column.column_attnum, serializer.validated_data)
109             except UndefinedFunction as e:
110                 raise database_api_exceptions.UndefinedFunctionAPIException(
111                     e,
112                     message='This type cast is not implemented',
113                     status_code=status.HTTP_400_BAD_REQUEST
114                 )
115             except ProgrammingError as e:
116                 raise database_base_api_exceptions.ProgrammingAPIException(
117                     e,
118                     status_code=status.HTTP_400_BAD_REQUEST
119                 )
120             except IndexError as e:
121                 raise base_api_exceptions.NotFoundAPIException(e)
122             except TypeError as e:
123                 raise database_api_exceptions.InvalidTypeOptionAPIException(
124                     e,
125                     message="Unknown type_option passed",
126                     status_code=status.HTTP_400_BAD_REQUEST
127                 )
128             except InvalidDefaultError as e:
129                 raise database_api_exceptions.InvalidDefaultAPIException(
130                     e,
131                     message=f'default "{request.data["default"]}" is invalid for this column',
132                     status_code=status.HTTP_400_BAD_REQUEST
133                 )
134             except DynamicDefaultWarning as e:
135                 raise database_api_exceptions.DynamicDefaultAPIException(
136                     e,
137                     message='Changing type of columns with dynamically-generated defaults is not supported.'
138                             'Delete or change the default first.',
139                     status_code=status.HTTP_400_BAD_REQUEST
140                 )
141             except (InvalidTypeOptionError, InvalidTypeParameters) as e:
142                 type_options = request.data.get('type_options', '')
143                 raise database_api_exceptions.InvalidTypeOptionAPIException(
144                     e,
145                     message=f'parameter dict {type_options} is invalid for type {request.data["type"]}',
146                     status_code=status.HTTP_400_BAD_REQUEST
147                 )
148             except InvalidTypeError as e:
149                 raise database_api_exceptions.InvalidTypeCastAPIException(
150                     e,
151                     message='This type casting is invalid.',
152                     status_code=status.HTTP_400_BAD_REQUEST
153                 )
154             except Exception as e:
155                 raise base_api_exceptions.MathesarAPIException(e)
156 
157         serializer.update(column_instance, serializer.validated_model_fields)
158         # Invalidate the cache as the underlying columns have changed
159         column_instance = self.get_object()
160         out_serializer = ColumnSerializer(column_instance)
161         return Response(out_serializer.data)
162 
163     def destroy(self, request, pk=None, table_pk=None):
164         column_instance = self.get_object()
165         table = column_instance.table
166         try:
167             table.drop_column(column_instance.attnum)
168             column_instance.delete()
169         except IndexError:
170             raise NotFound
171         return Response(status=status.HTTP_204_NO_CONTENT)
172
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mathesar/api/db/viewsets/columns.py b/mathesar/api/db/viewsets/columns.py
--- a/mathesar/api/db/viewsets/columns.py
+++ b/mathesar/api/db/viewsets/columns.py
@@ -27,7 +27,7 @@
     pagination_class = DefaultLimitOffsetPagination
 
     def get_queryset(self):
-        return Column.objects.filter(table=self.kwargs['table_pk'])
+        return Column.objects.filter(table=self.kwargs['table_pk']).order_by('attnum')
 
     def create(self, request, table_pk=None):
         table = get_table_or_404(table_pk)

{"golden_diff": "diff --git a/mathesar/api/db/viewsets/columns.py b/mathesar/api/db/viewsets/columns.py\n--- a/mathesar/api/db/viewsets/columns.py\n+++ b/mathesar/api/db/viewsets/columns.py\n@@ -27,7 +27,7 @@\n     pagination_class = DefaultLimitOffsetPagination\n \n     def get_queryset(self):\n-        return Column.objects.filter(table=self.kwargs['table_pk'])\n+        return Column.objects.filter(table=self.kwargs['table_pk']).order_by('attnum')\n \n     def create(self, request, table_pk=None):\n         table = get_table_or_404(table_pk)\n", "issue": "Columns re-ordered after type change\n## Reproduce\r\n\r\n1. \"New Table\" > \"Import Data\" > \"Copy and Paste Text\"\r\n\r\n1. Paste the following data and proceed to create and view the table (by clicking \"Continue\" and then \"Finish Import\").\r\n\r\n    ```\r\n    id,a,b\r\n    1,100,200\r\n    2,101,201\r\n    ```\r\n\r\n1. Click on the column header for column `a` and change the type from \"Number\" to \"Text\", clicking \"Save\".\r\n\r\n1. Expect columns to be ordered `id`, `a`, `b`.\r\n\r\n1. Once I did this and observed the columns to be ordered `a`, `id`, `b`. Another time. I observed the columns to be ordered `id`, `b`, `a`. I'm not sure what affects the ordering of the columns, but the order seems to remain consistent (even if incorrect) after the type-change operation.\r\n\r\n## Implementation\r\nThe backend should make sure that the column list in the API should always be ordered by suitable `index`.\r\n\r\n## Additional details\r\n\r\n- The front end displays the columns in the order it receives them from the columns API. In this case the API is returning the columns out-of-order, which is why I've marked this as a backend bug.\r\n- A while back, we had a [discussion about whether the user should be able to re-order columns](https://github.com/centerofci/mathesar/discussions/803) in which we decided _not_ to support re-ordering columns, at least for now.\r\n\n", "before_files": [{"content": "import warnings\nfrom psycopg2.errors import DuplicateColumn\nfrom rest_framework import status, viewsets\nfrom rest_framework.exceptions import NotFound\nfrom rest_framework.response import Response\nfrom sqlalchemy.exc import ProgrammingError\n\nfrom mathesar.api.exceptions.database_exceptions import (\n    exceptions as database_api_exceptions,\n    base_exceptions as database_base_api_exceptions,\n)\nfrom mathesar.api.exceptions.generic_exceptions import base_exceptions as base_api_exceptions\nfrom db.columns.exceptions import (\n    DynamicDefaultWarning, InvalidDefaultError, InvalidTypeOptionError, InvalidTypeError,\n)\nfrom db.columns.operations.select import get_column_attnum_from_name\nfrom db.types.exceptions import InvalidTypeParameters\nfrom db.records.exceptions import UndefinedFunction\nfrom mathesar.api.pagination import DefaultLimitOffsetPagination\nfrom mathesar.api.serializers.columns import ColumnSerializer\nfrom mathesar.api.utils import get_table_or_404\nfrom mathesar.models import Column\n\n\nclass ColumnViewSet(viewsets.ModelViewSet):\n    serializer_class = ColumnSerializer\n    pagination_class = DefaultLimitOffsetPagination\n\n    def get_queryset(self):\n        return Column.objects.filter(table=self.kwargs['table_pk'])\n\n    def create(self, request, table_pk=None):\n        table = get_table_or_404(table_pk)\n        # We only support adding a single column through the API.\n        serializer = ColumnSerializer(data=request.data, context={'request': request})\n        serializer.is_valid(raise_exception=True)\n        type_options = request.data.get('type_options', None)\n        if type_options is not None:\n            scale = type_options.get('scale', None)\n            precision = type_options.get('precision', None)\n            if scale is not None and precision is None:\n                request.data['type_options']['precision'] = 1000\n        if 'source_column' in serializer.validated_data:\n            column = table.duplicate_column(\n                serializer.validated_data['source_column'],\n                serializer.validated_data['copy_source_data'],\n                serializer.validated_data['copy_source_constraints'],\n                serializer.validated_data.get('name'),\n            )\n        else:\n            try:\n                # TODO Refactor add_column to user serializer validated date instead of request data\n                column = table.add_column(request.data)\n            except ProgrammingError as e:\n                if type(e.orig) == DuplicateColumn:\n                    name = request.data['name']\n                    raise database_api_exceptions.DuplicateTableAPIException(\n                        e,\n                        message=f'Column {name} already exists',\n                        field='name',\n                        status_code=status.HTTP_400_BAD_REQUEST\n                    )\n                else:\n                    raise database_base_api_exceptions.ProgrammingAPIException(e)\n            except TypeError as e:\n                raise base_api_exceptions.TypeErrorAPIException(\n                    e,\n                    message=\"Unknown type_option passed\",\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidDefaultError as e:\n                raise database_api_exceptions.InvalidDefaultAPIException(\n                    e,\n                    message=f'default \"{request.data[\"default\"]}\" is invalid for type {request.data[\"type\"]}',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except (InvalidTypeOptionError, InvalidTypeParameters) as e:\n                type_options = request.data.get('type_options', '')\n                raise database_api_exceptions.InvalidTypeOptionAPIException(\n                    e,\n                    message=f'parameter dict {type_options} is invalid for type {request.data[\"type\"]}',\n                    field=\"type_options\",\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidTypeError as e:\n                raise database_api_exceptions.InvalidTypeCastAPIException(\n                    e,\n                    message='This type casting is invalid.',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n        dj_column = Column(\n            table=table,\n            attnum=get_column_attnum_from_name(table.oid, column.name, table.schema._sa_engine),\n            **serializer.validated_model_fields\n        )\n        dj_column.save()\n        out_serializer = ColumnSerializer(dj_column)\n        return Response(out_serializer.data, status=status.HTTP_201_CREATED)\n\n    def partial_update(self, request, pk=None, table_pk=None):\n        column_instance = self.get_object()\n        table = column_instance.table\n        serializer = ColumnSerializer(instance=column_instance, data=request.data, partial=True)\n        serializer.is_valid(raise_exception=True)\n        with warnings.catch_warnings():\n            warnings.filterwarnings(\"error\", category=DynamicDefaultWarning)\n            try:\n                table.alter_column(column_instance._sa_column.column_attnum, serializer.validated_data)\n            except UndefinedFunction as e:\n                raise database_api_exceptions.UndefinedFunctionAPIException(\n                    e,\n                    message='This type cast is not implemented',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except ProgrammingError as e:\n                raise database_base_api_exceptions.ProgrammingAPIException(\n                    e,\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except IndexError as e:\n                raise base_api_exceptions.NotFoundAPIException(e)\n            except TypeError as e:\n                raise database_api_exceptions.InvalidTypeOptionAPIException(\n                    e,\n                    message=\"Unknown type_option passed\",\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidDefaultError as e:\n                raise database_api_exceptions.InvalidDefaultAPIException(\n                    e,\n                    message=f'default \"{request.data[\"default\"]}\" is invalid for this column',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except DynamicDefaultWarning as e:\n                raise database_api_exceptions.DynamicDefaultAPIException(\n                    e,\n                    message='Changing type of columns with dynamically-generated defaults is not supported.'\n                            'Delete or change the default first.',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except (InvalidTypeOptionError, InvalidTypeParameters) as e:\n                type_options = request.data.get('type_options', '')\n                raise database_api_exceptions.InvalidTypeOptionAPIException(\n                    e,\n                    message=f'parameter dict {type_options} is invalid for type {request.data[\"type\"]}',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidTypeError as e:\n                raise database_api_exceptions.InvalidTypeCastAPIException(\n                    e,\n                    message='This type casting is invalid.',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except Exception as e:\n                raise base_api_exceptions.MathesarAPIException(e)\n\n        serializer.update(column_instance, serializer.validated_model_fields)\n        # Invalidate the cache as the underlying columns have changed\n        column_instance = self.get_object()\n        out_serializer = ColumnSerializer(column_instance)\n        return Response(out_serializer.data)\n\n    def destroy(self, request, pk=None, table_pk=None):\n        column_instance = self.get_object()\n        table = column_instance.table\n        try:\n            table.drop_column(column_instance.attnum)\n            column_instance.delete()\n        except IndexError:\n            raise NotFound\n        return Response(status=status.HTTP_204_NO_CONTENT)\n", "path": "mathesar/api/db/viewsets/columns.py"}], "after_files": [{"content": "import warnings\nfrom psycopg2.errors import DuplicateColumn\nfrom rest_framework import status, viewsets\nfrom rest_framework.exceptions import NotFound\nfrom rest_framework.response import Response\nfrom sqlalchemy.exc import ProgrammingError\n\nfrom mathesar.api.exceptions.database_exceptions import (\n    exceptions as database_api_exceptions,\n    base_exceptions as database_base_api_exceptions,\n)\nfrom mathesar.api.exceptions.generic_exceptions import base_exceptions as base_api_exceptions\nfrom db.columns.exceptions import (\n    DynamicDefaultWarning, InvalidDefaultError, InvalidTypeOptionError, InvalidTypeError,\n)\nfrom db.columns.operations.select import get_column_attnum_from_name\nfrom db.types.exceptions import InvalidTypeParameters\nfrom db.records.exceptions import UndefinedFunction\nfrom mathesar.api.pagination import DefaultLimitOffsetPagination\nfrom mathesar.api.serializers.columns import ColumnSerializer\nfrom mathesar.api.utils import get_table_or_404\nfrom mathesar.models import Column\n\n\nclass ColumnViewSet(viewsets.ModelViewSet):\n    serializer_class = ColumnSerializer\n    pagination_class = DefaultLimitOffsetPagination\n\n    def get_queryset(self):\n        return Column.objects.filter(table=self.kwargs['table_pk']).order_by('attnum')\n\n    def create(self, request, table_pk=None):\n        table = get_table_or_404(table_pk)\n        # We only support adding a single column through the API.\n        serializer = ColumnSerializer(data=request.data, context={'request': request})\n        serializer.is_valid(raise_exception=True)\n        type_options = request.data.get('type_options', None)\n        if type_options is not None:\n            scale = type_options.get('scale', None)\n            precision = type_options.get('precision', None)\n            if scale is not None and precision is None:\n                request.data['type_options']['precision'] = 1000\n        if 'source_column' in serializer.validated_data:\n            column = table.duplicate_column(\n                serializer.validated_data['source_column'],\n                serializer.validated_data['copy_source_data'],\n                serializer.validated_data['copy_source_constraints'],\n                serializer.validated_data.get('name'),\n            )\n        else:\n            try:\n                # TODO Refactor add_column to user serializer validated date instead of request data\n                column = table.add_column(request.data)\n            except ProgrammingError as e:\n                if type(e.orig) == DuplicateColumn:\n                    name = request.data['name']\n                    raise database_api_exceptions.DuplicateTableAPIException(\n                        e,\n                        message=f'Column {name} already exists',\n                        field='name',\n                        status_code=status.HTTP_400_BAD_REQUEST\n                    )\n                else:\n                    raise database_base_api_exceptions.ProgrammingAPIException(e)\n            except TypeError as e:\n                raise base_api_exceptions.TypeErrorAPIException(\n                    e,\n                    message=\"Unknown type_option passed\",\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidDefaultError as e:\n                raise database_api_exceptions.InvalidDefaultAPIException(\n                    e,\n                    message=f'default \"{request.data[\"default\"]}\" is invalid for type {request.data[\"type\"]}',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except (InvalidTypeOptionError, InvalidTypeParameters) as e:\n                type_options = request.data.get('type_options', '')\n                raise database_api_exceptions.InvalidTypeOptionAPIException(\n                    e,\n                    message=f'parameter dict {type_options} is invalid for type {request.data[\"type\"]}',\n                    field=\"type_options\",\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidTypeError as e:\n                raise database_api_exceptions.InvalidTypeCastAPIException(\n                    e,\n                    message='This type casting is invalid.',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n        dj_column = Column(\n            table=table,\n            attnum=get_column_attnum_from_name(table.oid, column.name, table.schema._sa_engine),\n            **serializer.validated_model_fields\n        )\n        dj_column.save()\n        out_serializer = ColumnSerializer(dj_column)\n        return Response(out_serializer.data, status=status.HTTP_201_CREATED)\n\n    def partial_update(self, request, pk=None, table_pk=None):\n        column_instance = self.get_object()\n        table = column_instance.table\n        serializer = ColumnSerializer(instance=column_instance, data=request.data, partial=True)\n        serializer.is_valid(raise_exception=True)\n        with warnings.catch_warnings():\n            warnings.filterwarnings(\"error\", category=DynamicDefaultWarning)\n            try:\n                table.alter_column(column_instance._sa_column.column_attnum, serializer.validated_data)\n            except UndefinedFunction as e:\n                raise database_api_exceptions.UndefinedFunctionAPIException(\n                    e,\n                    message='This type cast is not implemented',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except ProgrammingError as e:\n                raise database_base_api_exceptions.ProgrammingAPIException(\n                    e,\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except IndexError as e:\n                raise base_api_exceptions.NotFoundAPIException(e)\n            except TypeError as e:\n                raise database_api_exceptions.InvalidTypeOptionAPIException(\n                    e,\n                    message=\"Unknown type_option passed\",\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidDefaultError as e:\n                raise database_api_exceptions.InvalidDefaultAPIException(\n                    e,\n                    message=f'default \"{request.data[\"default\"]}\" is invalid for this column',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except DynamicDefaultWarning as e:\n                raise database_api_exceptions.DynamicDefaultAPIException(\n                    e,\n                    message='Changing type of columns with dynamically-generated defaults is not supported.'\n                            'Delete or change the default first.',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except (InvalidTypeOptionError, InvalidTypeParameters) as e:\n                type_options = request.data.get('type_options', '')\n                raise database_api_exceptions.InvalidTypeOptionAPIException(\n                    e,\n                    message=f'parameter dict {type_options} is invalid for type {request.data[\"type\"]}',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except InvalidTypeError as e:\n                raise database_api_exceptions.InvalidTypeCastAPIException(\n                    e,\n                    message='This type casting is invalid.',\n                    status_code=status.HTTP_400_BAD_REQUEST\n                )\n            except Exception as e:\n                raise base_api_exceptions.MathesarAPIException(e)\n\n        serializer.update(column_instance, serializer.validated_model_fields)\n        # Invalidate the cache as the underlying columns have changed\n        column_instance = self.get_object()\n        out_serializer = ColumnSerializer(column_instance)\n        return Response(out_serializer.data)\n\n    def destroy(self, request, pk=None, table_pk=None):\n        column_instance = self.get_object()\n        table = column_instance.table\n        try:\n            table.drop_column(column_instance.attnum)\n            column_instance.delete()\n        except IndexError:\n            raise NotFound\n        return Response(status=status.HTTP_204_NO_CONTENT)\n", "path": "mathesar/api/db/viewsets/columns.py"}]}