prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Implement filters for schema list API
  **Problem**
  <!-- Please provide a clear and concise description of the problem that this feature request is designed to solve.-->
  Users should be able to:
  - get schemas associated with a given database key from the schema list API.
  - filter schemas by name.
  
  **Proposed solution**
  <!-- A clear and concise description of your proposed solution or feature. -->
  Schema list API should take name and database filter parameters.
  
  **Additional context**
  <!-- Add any other context or screenshots about the feature request here.-->
  We should use `django-filter` for this.
  
  </issue>
  <code>
  [start of mathesar/views/api.py]
  1 from rest_framework import status, viewsets
  2 from rest_framework.exceptions import NotFound, ValidationError
  3 from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, CreateModelMixin
  4 from rest_framework.response import Response
  5 from django_filters import rest_framework as filters
  6 
  7 from mathesar.database.utils import get_non_default_database_keys
  8 from mathesar.models import Table, Schema, DataFile
  9 from mathesar.pagination import DefaultLimitOffsetPagination, TableLimitOffsetPagination
  10 from mathesar.serializers import TableSerializer, SchemaSerializer, RecordSerializer, DataFileSerializer
  11 from mathesar.utils.schemas import create_schema_and_object
  12 from mathesar.utils.api import create_table_from_datafile
  13 from mathesar.filters import TableFilter
  14 
  15 
  16 class SchemaViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):
  17     queryset = Schema.objects.all().order_by('-created_at')
  18     serializer_class = SchemaSerializer
  19     pagination_class = DefaultLimitOffsetPagination
  20 
  21     def create(self, request):
  22         schema = create_schema_and_object(request.data['name'], request.data['database'])
  23         serializer = SchemaSerializer(schema)
  24         return Response(serializer.data, status=status.HTTP_201_CREATED)
  25 
  26 
  27 class TableViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin,
  28                    CreateModelMixin):
  29     queryset = Table.objects.all().order_by('-created_at')
  30     serializer_class = TableSerializer
  31     pagination_class = DefaultLimitOffsetPagination
  32     filter_backends = (filters.DjangoFilterBackend,)
  33     filterset_class = TableFilter
  34 
  35     def create(self, request):
  36         serializer = TableSerializer(data=request.data,
  37                                      context={'request': request})
  38         if serializer.is_valid():
  39             return create_table_from_datafile(request, serializer.data)
  40         else:
  41             raise ValidationError(serializer.errors)
  42 
  43 
  44 class RecordViewSet(viewsets.ViewSet):
  45     # There is no "update" method.
  46     # We're not supporting PUT requests because there aren't a lot of use cases
  47     # where the entire record needs to be replaced, PATCH suffices for updates.
  48     queryset = Table.objects.all().order_by('-created_at')
  49 
  50     def list(self, request, table_pk=None):
  51         paginator = TableLimitOffsetPagination()
  52         records = paginator.paginate_queryset(self.queryset, request, table_pk)
  53         serializer = RecordSerializer(records, many=True)
  54         return paginator.get_paginated_response(serializer.data)
  55 
  56     def retrieve(self, request, pk=None, table_pk=None):
  57         table = Table.objects.get(id=table_pk)
  58         record = table.get_record(pk)
  59         if not record:
  60             raise NotFound
  61         serializer = RecordSerializer(record)
  62         return Response(serializer.data)
  63 
  64     def create(self, request, table_pk=None):
  65         table = Table.objects.get(id=table_pk)
  66         # We only support adding a single record through the API.
  67         assert isinstance((request.data), dict)
  68         record = table.create_record_or_records(request.data)
  69         serializer = RecordSerializer(record)
  70         return Response(serializer.data, status=status.HTTP_201_CREATED)
  71 
  72     def partial_update(self, request, pk=None, table_pk=None):
  73         table = Table.objects.get(id=table_pk)
  74         record = table.update_record(pk, request.data)
  75         serializer = RecordSerializer(record)
  76         return Response(serializer.data)
  77 
  78     def destroy(self, request, pk=None, table_pk=None):
  79         table = Table.objects.get(id=table_pk)
  80         table.delete_record(pk)
  81         return Response(status=status.HTTP_204_NO_CONTENT)
  82 
  83 
  84 class DatabaseKeyViewSet(viewsets.ViewSet):
  85     def list(self, request):
  86         return Response(get_non_default_database_keys())
  87 
  88 
  89 class DataFileViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin, CreateModelMixin):
  90     queryset = DataFile.objects.all().order_by('-created_at')
  91     serializer_class = DataFileSerializer
  92     pagination_class = DefaultLimitOffsetPagination
  93
  [end of mathesar/views/api.py]
  [start of mathesar/filters.py]
  1 from django_filters import rest_framework as filters
  2 
  3 from mathesar.models import Table
  4 
  5 
  6 class CharInFilter(filters.BaseInFilter, filters.CharFilter):
  7     pass
  8 
  9 
  10 class TableFilter(filters.FilterSet):
  11     name = CharInFilter(field_name='name', lookup_expr='in')
  12 
  13     class Meta:
  14         model = Table
  15         fields = ['name']
  16
  [end of mathesar/filters.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mathesar/filters.py b/mathesar/filters.py
  --- a/mathesar/filters.py
  +++ b/mathesar/filters.py
  @@ -1,12 +1,21 @@
   from django_filters import rest_framework as filters
   
  -from mathesar.models import Table
  +from mathesar.models import Schema, Table
   
   
   class CharInFilter(filters.BaseInFilter, filters.CharFilter):
       pass
   
   
  +class SchemaFilter(filters.FilterSet):
  +    name = CharInFilter(field_name='name', lookup_expr='in')
  +    database = CharInFilter(field_name='database', lookup_expr='in')
  +
  +    class Meta:
  +        model = Schema
  +        fields = ['name', 'database']
  +
  +
   class TableFilter(filters.FilterSet):
       name = CharInFilter(field_name='name', lookup_expr='in')
   
  diff --git a/mathesar/views/api.py b/mathesar/views/api.py
  --- a/mathesar/views/api.py
  +++ b/mathesar/views/api.py
  @@ -10,13 +10,15 @@
   from mathesar.serializers import TableSerializer, SchemaSerializer, RecordSerializer, DataFileSerializer
   from mathesar.utils.schemas import create_schema_and_object
   from mathesar.utils.api import create_table_from_datafile
  -from mathesar.filters import TableFilter
  +from mathesar.filters import SchemaFilter, TableFilter
   
   
   class SchemaViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):
       queryset = Schema.objects.all().order_by('-created_at')
       serializer_class = SchemaSerializer
       pagination_class = DefaultLimitOffsetPagination
  +    filter_backends = (filters.DjangoFilterBackend,)
  +    filterset_class = SchemaFilter
   
       def create(self, request):
           schema = create_schema_and_object(request.data['name'], request.data['database'])
  
verification_info: {"golden_diff": "diff --git a/mathesar/filters.py b/mathesar/filters.py\n--- a/mathesar/filters.py\n+++ b/mathesar/filters.py\n@@ -1,12 +1,21 @@\n from django_filters import rest_framework as filters\n \n-from mathesar.models import Table\n+from mathesar.models import Schema, Table\n \n \n class CharInFilter(filters.BaseInFilter, filters.CharFilter):\n     pass\n \n \n+class SchemaFilter(filters.FilterSet):\n+    name = CharInFilter(field_name='name', lookup_expr='in')\n+    database = CharInFilter(field_name='database', lookup_expr='in')\n+\n+    class Meta:\n+        model = Schema\n+        fields = ['name', 'database']\n+\n+\n class TableFilter(filters.FilterSet):\n     name = CharInFilter(field_name='name', lookup_expr='in')\n \ndiff --git a/mathesar/views/api.py b/mathesar/views/api.py\n--- a/mathesar/views/api.py\n+++ b/mathesar/views/api.py\n@@ -10,13 +10,15 @@\n from mathesar.serializers import TableSerializer, SchemaSerializer, RecordSerializer, DataFileSerializer\n from mathesar.utils.schemas import create_schema_and_object\n from mathesar.utils.api import create_table_from_datafile\n-from mathesar.filters import TableFilter\n+from mathesar.filters import SchemaFilter, TableFilter\n \n \n class SchemaViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):\n     queryset = Schema.objects.all().order_by('-created_at')\n     serializer_class = SchemaSerializer\n     pagination_class = DefaultLimitOffsetPagination\n+    filter_backends = (filters.DjangoFilterBackend,)\n+    filterset_class = SchemaFilter\n \n     def create(self, request):\n         schema = create_schema_and_object(request.data['name'], request.data['database'])\n", "issue": "Implement filters for schema list API\n**Problem**\r\n<!-- Please provide a clear and concise description of the problem that this feature request is designed to solve.-->\r\nUsers should be able to:\r\n- get schemas associated with a given database key from the schema list API.\r\n- filter schemas by name.\r\n\r\n**Proposed solution**\r\n<!-- A clear and concise description of your proposed solution or feature. -->\r\nSchema list API should take name and database filter parameters.\r\n\r\n**Additional context**\r\n<!-- Add any other context or screenshots about the feature request here.-->\r\nWe should use `django-filter` for this.\n", "before_files": [{"content": "from rest_framework import status, viewsets\nfrom rest_framework.exceptions import NotFound, ValidationError\nfrom rest_framework.mixins import ListModelMixin, RetrieveModelMixin, CreateModelMixin\nfrom rest_framework.response import Response\nfrom django_filters import rest_framework as filters\n\nfrom mathesar.database.utils import get_non_default_database_keys\nfrom mathesar.models import Table, Schema, DataFile\nfrom mathesar.pagination import DefaultLimitOffsetPagination, TableLimitOffsetPagination\nfrom mathesar.serializers import TableSerializer, SchemaSerializer, RecordSerializer, DataFileSerializer\nfrom mathesar.utils.schemas import create_schema_and_object\nfrom mathesar.utils.api import create_table_from_datafile\nfrom mathesar.filters import TableFilter\n\n\nclass SchemaViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):\n    queryset = Schema.objects.all().order_by('-created_at')\n    serializer_class = SchemaSerializer\n    pagination_class = DefaultLimitOffsetPagination\n\n    def create(self, request):\n        schema = create_schema_and_object(request.data['name'], request.data['database'])\n        serializer = SchemaSerializer(schema)\n        return Response(serializer.data, status=status.HTTP_201_CREATED)\n\n\nclass TableViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin,\n                   CreateModelMixin):\n    queryset = Table.objects.all().order_by('-created_at')\n    serializer_class = TableSerializer\n    pagination_class = DefaultLimitOffsetPagination\n    filter_backends = (filters.DjangoFilterBackend,)\n    filterset_class = TableFilter\n\n    def create(self, request):\n        serializer = TableSerializer(data=request.data,\n                                     context={'request': request})\n        if serializer.is_valid():\n            return create_table_from_datafile(request, serializer.data)\n        else:\n            raise ValidationError(serializer.errors)\n\n\nclass RecordViewSet(viewsets.ViewSet):\n    # There is no \"update\" method.\n    # We're not supporting PUT requests because there aren't a lot of use cases\n    # where the entire record needs to be replaced, PATCH suffices for updates.\n    queryset = Table.objects.all().order_by('-created_at')\n\n    def list(self, request, table_pk=None):\n        paginator = TableLimitOffsetPagination()\n        records = paginator.paginate_queryset(self.queryset, request, table_pk)\n        serializer = RecordSerializer(records, many=True)\n        return paginator.get_paginated_response(serializer.data)\n\n    def retrieve(self, request, pk=None, table_pk=None):\n        table = Table.objects.get(id=table_pk)\n        record = table.get_record(pk)\n        if not record:\n            raise NotFound\n        serializer = RecordSerializer(record)\n        return Response(serializer.data)\n\n    def create(self, request, table_pk=None):\n        table = Table.objects.get(id=table_pk)\n        # We only support adding a single record through the API.\n        assert isinstance((request.data), dict)\n        record = table.create_record_or_records(request.data)\n        serializer = RecordSerializer(record)\n        return Response(serializer.data, status=status.HTTP_201_CREATED)\n\n    def partial_update(self, request, pk=None, table_pk=None):\n        table = Table.objects.get(id=table_pk)\n        record = table.update_record(pk, request.data)\n        serializer = RecordSerializer(record)\n        return Response(serializer.data)\n\n    def destroy(self, request, pk=None, table_pk=None):\n        table = Table.objects.get(id=table_pk)\n        table.delete_record(pk)\n        return Response(status=status.HTTP_204_NO_CONTENT)\n\n\nclass DatabaseKeyViewSet(viewsets.ViewSet):\n    def list(self, request):\n        return Response(get_non_default_database_keys())\n\n\nclass DataFileViewSet(viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin, CreateModelMixin):\n    queryset = DataFile.objects.all().order_by('-created_at')\n    serializer_class = DataFileSerializer\n    pagination_class = DefaultLimitOffsetPagination\n", "path": "mathesar/views/api.py"}, {"content": "from django_filters import rest_framework as filters\n\nfrom mathesar.models import Table\n\n\nclass CharInFilter(filters.BaseInFilter, filters.CharFilter):\n    pass\n\n\nclass TableFilter(filters.FilterSet):\n    name = CharInFilter(field_name='name', lookup_expr='in')\n\n    class Meta:\n        model = Table\n        fields = ['name']\n", "path": "mathesar/filters.py"}]}