We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Explorations should not auto-save
New Explorations are currently persistent, any change made immediately saves the exploration. This behaviour is not preferred since we'd like the user to be able to run and discard queries.

[Mail thread containing related discussion](https://groups.google.com/a/mathesar.org/g/mathesar-developers/c/RQJSiDQu1Tg/m/uLHj30yFAgAJ).

New behaviour proposed:

* New Exploration: Auto-save is not preferred
  - User opens Data Explorer
  - User joins tables, does any number of operations
  - This should not get saved automatically
  - It should get saved when user manually clicks Save button

* Editing existing Exploration: ~~Auto-save is preferred~~ Auto save is not preferred (Refer https://github.com/centerofci/mathesar/issues/1590#issuecomment-1238204655)
  - Users edits an existing exploration in the Data Explorer
  - User makes changes to it
  - ~~The changes are auto-saved~~ User has to click the Save button or Ctrl+s to save the changes
  - We have undo-redo to improve the user's editing experience
Implement Exploration Page functionality
This is a placeholder issue to implement a page to view a single exploration.

--- 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/views.py`
Content:
```
1 from django.shortcuts import render, redirect, get_object_or_404
2 
3 from mathesar.models.base import Database, Schema, Table
4 from mathesar.api.serializers.databases import DatabaseSerializer, TypeSerializer
5 from mathesar.api.serializers.schemas import SchemaSerializer
6 from mathesar.api.serializers.tables import TableSerializer
7 from mathesar.api.serializers.queries import QuerySerializer
8 from mathesar.database.types import UIType
9 from mathesar.models.query import UIQuery
10 
11 
12 def get_schema_list(request, database):
13     schema_serializer = SchemaSerializer(
14         Schema.objects.filter(database=database),
15         many=True,
16         context={'request': request}
17     )
18     return schema_serializer.data
19 
20 
21 def get_database_list(request):
22     database_serializer = DatabaseSerializer(
23         Database.objects.all(),
24         many=True,
25         context={'request': request}
26     )
27     return database_serializer.data
28 
29 
30 def get_table_list(request, schema):
31     if schema is None:
32         return []
33     table_serializer = TableSerializer(
34         Table.objects.filter(schema=schema),
35         many=True,
36         context={'request': request}
37     )
38     return table_serializer.data
39 
40 
41 def get_queries_list(request, schema):
42     if schema is None:
43         return []
44     query_serializer = QuerySerializer(
45         UIQuery.objects.all(),
46         many=True,
47         context={'request': request}
48     )
49     return query_serializer.data
50 
51 
52 def get_ui_type_list(request, database):
53     if database is None:
54         return []
55     type_serializer = TypeSerializer(
56         UIType,
57         many=True,
58         context={'request': request}
59     )
60     return type_serializer.data
61 
62 
63 def get_common_data(request, database, schema=None):
64     return {
65         'current_db': database.name if database else None,
66         'current_schema': schema.id if schema else None,
67         'schemas': get_schema_list(request, database),
68         'databases': get_database_list(request),
69         'tables': get_table_list(request, schema),
70         'queries': get_queries_list(request, schema),
71         'abstract_types': get_ui_type_list(request, database)
72     }
73 
74 
75 def get_current_database(request, db_name):
76     # if there's a DB name passed in, try to retrieve the database, or return a 404 error.
77     if db_name is not None:
78         return get_object_or_404(Database, name=db_name)
79     else:
80         try:
81             # Try to get the first database available
82             return Database.objects.order_by('id').first()
83         except Database.DoesNotExist:
84             return None
85 
86 
87 def get_current_schema(request, schema_id, database):
88     # if there's a schema ID passed in, try to retrieve the schema, or return a 404 error.
89     if schema_id is not None:
90         return get_object_or_404(Schema, id=schema_id)
91     else:
92         try:
93             # Try to get the first schema in the DB
94             return Schema.objects.filter(database=database).order_by('id').first()
95         except Schema.DoesNotExist:
96             return None
97 
98 
99 def render_schema(request, database, schema):
100     # if there's no schema available, redirect to the schemas page.
101     if not schema:
102         return redirect('schemas', db_name=database.name)
103     else:
104         # We are redirecting so that the correct URL is passed to the frontend.
105         return redirect('schema_home', db_name=database.name, schema_id=schema.id)
106 
107 
108 def home(request):
109     database = get_current_database(request, None)
110     return redirect('schemas', db_name=database.name)
111 
112 
113 def schema_home(request, db_name, schema_id, **kwargs):
114     database = get_current_database(request, db_name)
115     schema = get_current_schema(request, schema_id, database)
116     return render(request, 'mathesar/index.html', {
117         'common_data': get_common_data(request, database, schema)
118     })
119 
120 
121 def schemas(request, db_name):
122     database = get_current_database(request, db_name)
123     return render(request, 'mathesar/index.html', {
124         'common_data': get_common_data(request, database, None)
125     })
126
```
--- 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/views.py b/mathesar/views.py
--- a/mathesar/views.py
+++ b/mathesar/views.py
@@ -42,7 +42,7 @@
     if schema is None:
         return []
     query_serializer = QuerySerializer(
-        UIQuery.objects.all(),
+        UIQuery.objects.filter(base_table__schema=schema),
         many=True,
         context={'request': request}
     )

{"golden_diff": "diff --git a/mathesar/views.py b/mathesar/views.py\n--- a/mathesar/views.py\n+++ b/mathesar/views.py\n@@ -42,7 +42,7 @@\n     if schema is None:\n         return []\n     query_serializer = QuerySerializer(\n-        UIQuery.objects.all(),\n+        UIQuery.objects.filter(base_table__schema=schema),\n         many=True,\n         context={'request': request}\n     )\n", "issue": "Explorations should not auto-save\nNew Explorations are currently persistent, any change made immediately saves the exploration. This behaviour is not preferred since we'd like the user to be able to run and discard queries.\r\n\r\n[Mail thread containing related discussion](https://groups.google.com/a/mathesar.org/g/mathesar-developers/c/RQJSiDQu1Tg/m/uLHj30yFAgAJ).\r\n\r\nNew behaviour proposed:\r\n\r\n* New Exploration: Auto-save is not preferred\r\n  - User opens Data Explorer\r\n  - User joins tables, does any number of operations\r\n  - This should not get saved automatically\r\n  - It should get saved when user manually clicks Save button\r\n\r\n* Editing existing Exploration: ~~Auto-save is preferred~~ Auto save is not preferred (Refer https://github.com/centerofci/mathesar/issues/1590#issuecomment-1238204655)\r\n  - Users edits an existing exploration in the Data Explorer\r\n  - User makes changes to it\r\n  - ~~The changes are auto-saved~~ User has to click the Save button or Ctrl+s to save the changes\r\n  - We have undo-redo to improve the user's editing experience\nImplement Exploration Page functionality\nThis is a placeholder issue to implement a page to view a single exploration.\n", "before_files": [{"content": "from django.shortcuts import render, redirect, get_object_or_404\n\nfrom mathesar.models.base import Database, Schema, Table\nfrom mathesar.api.serializers.databases import DatabaseSerializer, TypeSerializer\nfrom mathesar.api.serializers.schemas import SchemaSerializer\nfrom mathesar.api.serializers.tables import TableSerializer\nfrom mathesar.api.serializers.queries import QuerySerializer\nfrom mathesar.database.types import UIType\nfrom mathesar.models.query import UIQuery\n\n\ndef get_schema_list(request, database):\n    schema_serializer = SchemaSerializer(\n        Schema.objects.filter(database=database),\n        many=True,\n        context={'request': request}\n    )\n    return schema_serializer.data\n\n\ndef get_database_list(request):\n    database_serializer = DatabaseSerializer(\n        Database.objects.all(),\n        many=True,\n        context={'request': request}\n    )\n    return database_serializer.data\n\n\ndef get_table_list(request, schema):\n    if schema is None:\n        return []\n    table_serializer = TableSerializer(\n        Table.objects.filter(schema=schema),\n        many=True,\n        context={'request': request}\n    )\n    return table_serializer.data\n\n\ndef get_queries_list(request, schema):\n    if schema is None:\n        return []\n    query_serializer = QuerySerializer(\n        UIQuery.objects.all(),\n        many=True,\n        context={'request': request}\n    )\n    return query_serializer.data\n\n\ndef get_ui_type_list(request, database):\n    if database is None:\n        return []\n    type_serializer = TypeSerializer(\n        UIType,\n        many=True,\n        context={'request': request}\n    )\n    return type_serializer.data\n\n\ndef get_common_data(request, database, schema=None):\n    return {\n        'current_db': database.name if database else None,\n        'current_schema': schema.id if schema else None,\n        'schemas': get_schema_list(request, database),\n        'databases': get_database_list(request),\n        'tables': get_table_list(request, schema),\n        'queries': get_queries_list(request, schema),\n        'abstract_types': get_ui_type_list(request, database)\n    }\n\n\ndef get_current_database(request, db_name):\n    # if there's a DB name passed in, try to retrieve the database, or return a 404 error.\n    if db_name is not None:\n        return get_object_or_404(Database, name=db_name)\n    else:\n        try:\n            # Try to get the first database available\n            return Database.objects.order_by('id').first()\n        except Database.DoesNotExist:\n            return None\n\n\ndef get_current_schema(request, schema_id, database):\n    # if there's a schema ID passed in, try to retrieve the schema, or return a 404 error.\n    if schema_id is not None:\n        return get_object_or_404(Schema, id=schema_id)\n    else:\n        try:\n            # Try to get the first schema in the DB\n            return Schema.objects.filter(database=database).order_by('id').first()\n        except Schema.DoesNotExist:\n            return None\n\n\ndef render_schema(request, database, schema):\n    # if there's no schema available, redirect to the schemas page.\n    if not schema:\n        return redirect('schemas', db_name=database.name)\n    else:\n        # We are redirecting so that the correct URL is passed to the frontend.\n        return redirect('schema_home', db_name=database.name, schema_id=schema.id)\n\n\ndef home(request):\n    database = get_current_database(request, None)\n    return redirect('schemas', db_name=database.name)\n\n\ndef schema_home(request, db_name, schema_id, **kwargs):\n    database = get_current_database(request, db_name)\n    schema = get_current_schema(request, schema_id, database)\n    return render(request, 'mathesar/index.html', {\n        'common_data': get_common_data(request, database, schema)\n    })\n\n\ndef schemas(request, db_name):\n    database = get_current_database(request, db_name)\n    return render(request, 'mathesar/index.html', {\n        'common_data': get_common_data(request, database, None)\n    })\n", "path": "mathesar/views.py"}], "after_files": [{"content": "from django.shortcuts import render, redirect, get_object_or_404\n\nfrom mathesar.models.base import Database, Schema, Table\nfrom mathesar.api.serializers.databases import DatabaseSerializer, TypeSerializer\nfrom mathesar.api.serializers.schemas import SchemaSerializer\nfrom mathesar.api.serializers.tables import TableSerializer\nfrom mathesar.api.serializers.queries import QuerySerializer\nfrom mathesar.database.types import UIType\nfrom mathesar.models.query import UIQuery\n\n\ndef get_schema_list(request, database):\n    schema_serializer = SchemaSerializer(\n        Schema.objects.filter(database=database),\n        many=True,\n        context={'request': request}\n    )\n    return schema_serializer.data\n\n\ndef get_database_list(request):\n    database_serializer = DatabaseSerializer(\n        Database.objects.all(),\n        many=True,\n        context={'request': request}\n    )\n    return database_serializer.data\n\n\ndef get_table_list(request, schema):\n    if schema is None:\n        return []\n    table_serializer = TableSerializer(\n        Table.objects.filter(schema=schema),\n        many=True,\n        context={'request': request}\n    )\n    return table_serializer.data\n\n\ndef get_queries_list(request, schema):\n    if schema is None:\n        return []\n    query_serializer = QuerySerializer(\n        UIQuery.objects.filter(base_table__schema=schema),\n        many=True,\n        context={'request': request}\n    )\n    return query_serializer.data\n\n\ndef get_ui_type_list(request, database):\n    if database is None:\n        return []\n    type_serializer = TypeSerializer(\n        UIType,\n        many=True,\n        context={'request': request}\n    )\n    return type_serializer.data\n\n\ndef get_common_data(request, database, schema=None):\n    return {\n        'current_db': database.name if database else None,\n        'current_schema': schema.id if schema else None,\n        'schemas': get_schema_list(request, database),\n        'databases': get_database_list(request),\n        'tables': get_table_list(request, schema),\n        'queries': get_queries_list(request, schema),\n        'abstract_types': get_ui_type_list(request, database)\n    }\n\n\ndef get_current_database(request, db_name):\n    # if there's a DB name passed in, try to retrieve the database, or return a 404 error.\n    if db_name is not None:\n        return get_object_or_404(Database, name=db_name)\n    else:\n        try:\n            # Try to get the first database available\n            return Database.objects.order_by('id').first()\n        except Database.DoesNotExist:\n            return None\n\n\ndef get_current_schema(request, schema_id, database):\n    # if there's a schema ID passed in, try to retrieve the schema, or return a 404 error.\n    if schema_id is not None:\n        return get_object_or_404(Schema, id=schema_id)\n    else:\n        try:\n            # Try to get the first schema in the DB\n            return Schema.objects.filter(database=database).order_by('id').first()\n        except Schema.DoesNotExist:\n            return None\n\n\ndef render_schema(request, database, schema):\n    # if there's no schema available, redirect to the schemas page.\n    if not schema:\n        return redirect('schemas', db_name=database.name)\n    else:\n        # We are redirecting so that the correct URL is passed to the frontend.\n        return redirect('schema_home', db_name=database.name, schema_id=schema.id)\n\n\ndef home(request):\n    database = get_current_database(request, None)\n    return redirect('schemas', db_name=database.name)\n\n\ndef schema_home(request, db_name, schema_id, **kwargs):\n    database = get_current_database(request, db_name)\n    schema = get_current_schema(request, schema_id, database)\n    return render(request, 'mathesar/index.html', {\n        'common_data': get_common_data(request, database, schema)\n    })\n\n\ndef schemas(request, db_name):\n    database = get_current_database(request, db_name)\n    return render(request, 'mathesar/index.html', {\n        'common_data': get_common_data(request, database, None)\n    })\n", "path": "mathesar/views.py"}]}