Skip to content

Commit 68686e7

Browse files
authored
Merge pull request #4886 from mathesar-foundation/release-0.7.0
Release 0.7.0
2 parents e78b7f9 + f17fcc9 commit 68686e7

File tree

185 files changed

+104826
-1368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+104826
-1368
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Tech debt
3+
about: Improve Mathesar's codebase
4+
labels: "affects: technical debt, needs: triage"
5+
---
6+
7+
## Description
8+
<!-- A clear and concise description of what the problem is. -->
9+
10+
### Affects users
11+
<!-- Give a rating. Delete all but one -->
12+
**High**
13+
**Medium**
14+
**Low**
15+
**None**
16+
17+
<!-- If not "None", how does this debt affect users? -->
18+
19+
### Affects developers
20+
<!-- Give a rating. Delete all but one -->
21+
**High**
22+
**Medium**
23+
**Low**
24+
**None**
25+
26+
<!-- If not "None", how does this debt affect developers? -->
27+
28+
## Suggested change
29+
<!-- What is the proposed change to the codebase. -->
30+
31+
## Additional context
32+
<!-- Add any other context about the problem or screenshots here. -->
33+

DEVELOPER_GUIDE.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Mathesar is built using:
1010
- [Python](https://www.python.org/) for the backend
1111
- [Django](https://www.djangoproject.com/) for the web application
1212
- [SQLAlchemy](https://www.sqlalchemy.org/) to talk to the database
13-
- [Django REST Framework](https://www.django-rest-framework.org/) for the API
13+
- [Django REST Framework](https://www.django-rest-framework.org/) for the API
1414
- [Svelte](https://svelte.dev/) and [TypeScript](https://www.typescriptlang.org/) for the frontend
1515

1616
## Local development setup
@@ -77,7 +77,7 @@ We use [pytest](https://docs.pytest.org) for our backend tests.
7777
```
7878
docker exec mathesar_service_dev pytest -k "test_name"
7979
```
80-
80+
8181
- See the [pytest documentation](https://docs.pytest.org/en/latest/how-to/usage.html), or run pytest with the `--help` flag to learn about more options for running tests.
8282
8383
- Run all SQL tests:
@@ -183,7 +183,7 @@ Django uses gettext, which require the `.po` files to be compiled into a more ef
183183
## Translation process
184184
185185
- We use [Transifex](https://app.transifex.com/mathesar/mathesar/dashboard/) for managing our translation process.
186-
- You'll need to be a member of the Mathesar organization in Transifex, inorder to work with translations. Please reach out to us for information on how to join.
186+
- You'll need to be a member of the Mathesar organization in Transifex, inorder to work with translations. Please reach out to us for information on how to join.
187187
188188
### For Translators
189189
@@ -241,12 +241,34 @@ If you'd like to manually push or pull translations, follow the instructions in
241241
```
242242
docker exec -it mathesar_dev_db psql -U mathesar
243243
```
244-
244+
245+
## Working with file attachments
246+
247+
Mathesar has a feature which allows users to upload files through the UI and store references to those file in data. Uploaded files are stored in an S3-compatible storage provider.
248+
249+
To work with this feature in your local development environment, you'll need to take some extra steps to enable it:
250+
251+
1. Copy `file_storage.yml.example` to `file_storage.yml`.
252+
253+
1. Restart docker with the following command
254+
255+
```
256+
docker compose -f docker-compose.dev.yml up dev-service obj-store
257+
```
258+
259+
Notice that we start the `obj-store` service too, in addition to the normal `dev-service`.
260+
261+
1. Log in to the file storage backend UI at http://localhost:9001 with `mathesar`/`mathesar`. Create a new storage bucket in the UI called "mathesar-storages".
262+
263+
At this point you can run Mathesar and create new "File" columns in tables. Those columns will present a UI that allows you to attach files to table cells.
264+
265+
With the `obj-store` service running, you can return to http://localhost:9001 to view and manage your uploaded files.
266+
245267
## Troubleshooting
246268
247269
### Permissions within Windows
248270
249-
- Running Script in powershell is disabled by default in windows , you have to change permission to run scripts [Official Docs ](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2)
271+
- Running Script in powershell is disabled by default in windows , you have to change permission to run scripts [Official Docs ](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2)
250272
251273
### Fixing line endings on Windows
252274

db/columns.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
DESCRIPTION = "description"
99
NAME = "name"
1010
NULLABLE = "nullable"
11+
CAST_OPTIONS = "cast_options"
1112

1213

1314
def get_column_info_for_table(table, conn):
@@ -77,6 +78,7 @@ def _transform_column_alter_dict(data):
7778
"id": <int>,
7879
"name": <str>,
7980
"type": <str>,
81+
"cast_options": <dict>,
8082
"type_options": <dict>,
8183
"nullable": <bool>,
8284
"default": {"value": <any>}
@@ -87,6 +89,7 @@ def _transform_column_alter_dict(data):
8789
{
8890
"attnum": <int>,
8991
"type": {"name": <str>, "options": <dict>},
92+
"cast_options": {"curr_pref": <str>, "curr_suff": <str>, "decimal_p": <str>, "group_sep": <str>, "mathesar_casting": <bool>},
9093
"name": <str>,
9194
"not_null": <bool>,
9295
"default": <any>,
@@ -99,12 +102,14 @@ def _transform_column_alter_dict(data):
99102
"""
100103
type_ = {"name": data.get('type'), "options": data.get('type_options')}
101104
new_type = {k: v for k, v in type_.items() if v} or None
105+
cast_options = data.get(CAST_OPTIONS)
102106
nullable = data.get(NULLABLE)
103107
not_null = not nullable if nullable is not None else None
104108
column_name = (data.get(NAME) or '').strip() or None
105109
raw_alter_def = {
106110
"attnum": data["id"],
107111
"type": new_type,
112+
"cast_options": cast_options,
108113
"not_null": not_null,
109114
"name": column_name,
110115
"description": data.get("description")

db/records.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,35 @@ def patch_record_in_table(
195195
_json_or_none(table_record_summary_templates),
196196
).fetchone()[0]
197197
return result
198+
199+
200+
def insert_from_select(
201+
conn,
202+
src_table_id,
203+
dst_table_id,
204+
mappings
205+
):
206+
"""
207+
Insert multiple records from a given source table to a destination/target table,
208+
returning the number of records inserted.
209+
210+
Args:
211+
src_tab_id: The OID of the source table.(OID if temp table if inserting into existing table).
212+
dst_tab_id: The OID of the destination/target table.
213+
mappings: The column mappings b/w src and dst tables based on which data will be inserted.
214+
215+
mappings should have the following form:
216+
[
217+
{"src_table_attnum": 1, "dst_table_attnum": 2},
218+
{"src_table_attnum": 3, "dst_table_attnum": 3},
219+
{...}
220+
]
221+
"""
222+
result = db_conn.exec_msar_func(
223+
conn,
224+
'insert_from_select',
225+
src_table_id,
226+
dst_table_id,
227+
json.dumps(mappings)
228+
).fetchone()[0]
229+
return result

db/sql/00_msar_all_objects_table.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ INSERT INTO msar.all_mathesar_objects VALUES
3838
('__msar', '__msar.add_constraints(text,__msar.con_def[])', 'FUNCTION', NULL),
3939
('__msar', '__msar.add_table(text,__msar.col_def[],__msar.con_def[])', 'FUNCTION', NULL),
4040
('__msar', '__msar.build_cast_expr(text,text)', 'FUNCTION', NULL),
41+
('__msar', '__msar.build_cast_expr(text,text,jsonb)', 'FUNCTION', NULL),
4142
('__msar', '__msar.build_col_def_text(__msar.col_def)', 'FUNCTION', NULL),
4243
('__msar', '__msar.build_col_default_expr(oid,integer,text,jsonb,text)', 'FUNCTION', NULL),
4344
('__msar', '__msar.build_col_drop_default_expr(oid,integer,text,jsonb)', 'FUNCTION', NULL),
@@ -574,6 +575,7 @@ INSERT INTO msar.all_mathesar_objects VALUES
574575
('msar', 'msar.add_pkey_column(regclass,msar.pkey_kind,text)', 'FUNCTION', NULL),
575576
('msar', 'msar.add_record_to_table(oid,jsonb,boolean)', 'FUNCTION', NULL),
576577
('msar', 'msar.add_record_to_table(oid,jsonb,boolean,jsonb)', 'FUNCTION', NULL),
578+
('msar', 'msar.add_temp_table(text,__msar.col_def[])', 'FUNCTION', NULL),
577579
('msar', 'msar.add_time_to_vector(point,time without time zone)', 'FUNCTION', NULL),
578580
('msar', 'msar.all_mathesar_objects', 'TABLE', NULL),
579581
('msar', 'msar.all_mathesar_objects', 'TYPE', NULL),
@@ -595,6 +597,7 @@ INSERT INTO msar.all_mathesar_objects VALUES
595597
('msar', 'msar.build_grouping_results_jsonb_expr(oid,text,jsonb)', 'FUNCTION', NULL),
596598
('msar', 'msar.build_groups_cte_expr(oid,text,jsonb)', 'FUNCTION', NULL),
597599
('msar', 'msar.build_groups_cte_expr(oid,text,text,jsonb)', 'FUNCTION', NULL),
600+
('msar', 'msar.insert_from_select(regclass,regclass,jsonb)', 'FUNCTION', NULL),
598601
('msar', 'msar.build_insert_lookup_table(jsonb,jsonb)', 'FUNCTION', NULL),
599602
('msar', 'msar.build_linked_record_summaries_ctes(oid,jsonb)', 'FUNCTION', NULL),
600603
('msar', 'msar.build_order_by_expr(oid,jsonb)', 'FUNCTION', NULL),
@@ -1042,6 +1045,7 @@ INSERT INTO msar.all_mathesar_objects VALUES
10421045
('msar', 'msar.delete_records_from_table(oid,jsonb)', 'FUNCTION', NULL),
10431046
('msar', 'msar.describe_column_default(regclass,smallint)', 'FUNCTION', NULL),
10441047
('msar', 'msar.downsize_table_sample(numeric)', 'FUNCTION', NULL),
1048+
('msar', 'msar.drop_col_default(regclass,smallint)', 'FUNCTION', NULL),
10451049
('msar', 'msar.drop_columns(oid,integer[])', 'FUNCTION', NULL),
10461050
('msar', 'msar.drop_columns(text,text,text[])', 'FUNCTION', NULL),
10471051
('msar', 'msar.drop_constraint(oid,oid)', 'FUNCTION', NULL),
@@ -1171,6 +1175,7 @@ INSERT INTO msar.all_mathesar_objects VALUES
11711175
('msar', 'msar.point_to_time(point)', 'FUNCTION', NULL),
11721176
('msar', 'msar.prepare_table_for_import(oid,text,jsonb,boolean,text,text,text,text,text)', 'FUNCTION', NULL),
11731177
('msar', 'msar.prepare_table_for_import(oid,text,text[],text)', 'FUNCTION', NULL),
1178+
('msar', 'msar.prepare_temp_table_for_import(text,text[])', 'FUNCTION', NULL),
11741179
('msar', 'msar.process_col_alter_jsonb(oid,jsonb)', 'FUNCTION', NULL),
11751180
('msar', 'msar.process_col_def_jsonb(oid,jsonb,boolean,boolean)', 'FUNCTION', NULL),
11761181
('msar', 'msar.process_con_def_jsonb(oid,jsonb)', 'FUNCTION', NULL),
@@ -1183,6 +1188,8 @@ INSERT INTO msar.all_mathesar_objects VALUES
11831188
('msar', 'msar.replace_database_privileges_for_roles(jsonb)', 'FUNCTION', NULL),
11841189
('msar', 'msar.replace_schema_privileges_for_roles(regnamespace,jsonb)', 'FUNCTION', NULL),
11851190
('msar', 'msar.replace_table_privileges_for_roles(regclass,jsonb)', 'FUNCTION', NULL),
1191+
('msar', 'msar.retype_column(regclass,smallint,text)', 'FUNCTION', NULL),
1192+
('msar', 'msar.retype_column(regclass,smallint,text,jsonb)', 'FUNCTION', NULL),
11861193
('msar', 'msar.reset_mash(regclass,smallint,jsonb)', 'FUNCTION', NULL),
11871194
('msar', 'msar.role_info_table()', 'FUNCTION', NULL),
11881195
('msar', 'msar.sanitize_direction(text)', 'FUNCTION', NULL),
@@ -1191,8 +1198,11 @@ INSERT INTO msar.all_mathesar_objects VALUES
11911198
('msar', 'msar.search_records_from_table(oid,jsonb,integer,boolean)', 'FUNCTION', NULL),
11921199
('msar', 'msar.search_records_from_table(oid,jsonb,integer,boolean,jsonb)', 'FUNCTION', NULL),
11931200
('msar', 'msar.search_records_from_table(oid,jsonb,integer,integer,boolean,jsonb)', 'FUNCTION', NULL),
1201+
('msar', 'msar.set_col_default(regclass,smallint,text)', 'FUNCTION', NULL),
11941202
('msar', 'msar.set_members_to_role(regrole,oid[])', 'FUNCTION', NULL),
11951203
('msar', 'msar.set_not_null(regclass,smallint,boolean)', 'FUNCTION', NULL),
1204+
('msar', 'msar.set_old_col_default(regclass,smallint,text,text,boolean)', 'FUNCTION', NULL),
1205+
('msar', 'msar.set_old_col_default(regclass,smallint,text,text,boolean,jsonb)', 'FUNCTION', NULL),
11961206
('msar', 'msar.set_pkey_column(regclass,integer,msar.pkey_kind,boolean)', 'FUNCTION', NULL),
11971207
('msar', 'msar.set_schema_description(oid,text)', 'FUNCTION', NULL),
11981208
('msar', 'msar.table_info_table()', 'FUNCTION', NULL),

0 commit comments

Comments
 (0)