Skip to content

Commit 586e41e

Browse files
authored
Merge pull request #4972 from mathesar-foundation/0.7.1
Release Mathesar 0.7.1
2 parents e510c2c + 4d802be commit 586e41e

File tree

6 files changed

+171
-14
lines changed

6 files changed

+171
-14
lines changed

db/sql/05_msar.sql

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,10 +3654,22 @@ Args:
36543654
SELECT msar.get_cast_function_name(type_::regtype) || '(' ||
36553655
CONCAT_WS(', ',
36563656
val,
3657-
'group_sep =>' || quote_literal(cast_options ->> 'group_sep') || '::"char"',
3658-
'decimal_p =>' || quote_literal(cast_options ->> 'decimal_p') || '::"char"',
3659-
'curr_pref =>' || quote_literal(cast_options ->> 'curr_pref') || '::text',
3660-
'curr_suff =>' || quote_literal(cast_options ->> 'curr_suff') || '::text'
3657+
CASE WHEN NULLIF(cast_options, '{}'::jsonb) IS NOT NULL THEN
3658+
CASE type_::regtype
3659+
WHEN 'numeric'::regtype THEN
3660+
CONCAT_WS(', ',
3661+
'group_sep =>' || quote_literal(cast_options ->> 'group_sep') || '::"char"',
3662+
'decimal_p =>' || quote_literal(cast_options ->> 'decimal_p') || '::"char"'
3663+
)
3664+
WHEN 'mathesar_types.mathesar_money'::regtype THEN
3665+
CONCAT_WS(', ',
3666+
'group_sep =>' || quote_literal(cast_options ->> 'group_sep') || '::"char"',
3667+
'decimal_p =>' || quote_literal(cast_options ->> 'decimal_p') || '::"char"',
3668+
'curr_pref =>' || quote_literal(COALESCE(cast_options ->> 'curr_pref', '')) || '::text',
3669+
'curr_suff =>' || quote_literal(COALESCE(cast_options ->> 'curr_suff', '')) || '::text'
3670+
)
3671+
END
3672+
END
36613673
) || ')'
36623674
$$ LANGUAGE SQL RETURNS NULL ON NULL INPUT;
36633675

@@ -3763,7 +3775,7 @@ BEGIN
37633775
IF is_default_dynamic THEN
37643776
default_ := format('%s::%s', old_default, new_type);
37653777
ELSE
3766-
EXECUTE format('SELECT %s', __msar.build_cast_expr(old_default, new_type)) INTO default_;
3778+
EXECUTE format('SELECT %s', __msar.build_cast_expr(old_default, new_type, cast_options)) INTO default_;
37673779
default_ := quote_literal(default_);
37683780
END IF;
37693781

db/sql/test_sql_functions.sql

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ END;
16391639
$f$ LANGUAGE plpgsql;
16401640

16411641

1642-
CREATE OR REPLACE FUNCTION test_retype_col_sql() RETURNS SETOF TEXT AS $f$
1642+
CREATE OR REPLACE FUNCTION test_retype_col_sql_for_correct_inference() RETURNS SETOF TEXT AS $f$
16431643
DECLARE
16441644
tab_id regclass;
16451645
cast_options_1 jsonb := '{"mathesar_casting": true}'::jsonb;
@@ -1670,6 +1670,38 @@ END;
16701670
$f$ LANGUAGE plpgsql;
16711671

16721672

1673+
CREATE OR REPLACE FUNCTION test_retype_col_sql_for_incorrect_inference() RETURNS SETOF TEXT AS $f$
1674+
DECLARE
1675+
tab_id regclass;
1676+
cast_options_1 jsonb := '{"decimal_p": ".", "group_sep": "", "mathesar_casting": true}'::jsonb;
1677+
cast_options_2 jsonb := '{"curr_pref": "$", "curr_suff": "", "decimal_p": ".", "group_sep": ",", "mathesar_casting": true}'::jsonb;
1678+
BEGIN
1679+
PERFORM __setup_type_inference();
1680+
tab_id := '"Types Test"'::regclass;
1681+
-- retyping a column inferred as numeric to mathesar_types.mathesar_money instead of numeric
1682+
RETURN NEXT is(
1683+
msar.retype_column(tab_id, 5::smallint, 'mathesar_types.mathesar_money'::text, cast_options_1),
1684+
'ALTER TABLE public."Types Test" '
1685+
|| 'ALTER COLUMN "Numeric" TYPE mathesar_types.mathesar_money '
1686+
|| 'USING msar.cast_to_mathesar_money("Numeric", group_sep =>''''::"char", decimal_p =>''.''::"char", curr_pref =>''''::text, curr_suff =>''''::text)'
1687+
);
1688+
-- retyping a column inferred as mathesar_types.mathesar_money to numeric instead of mathesar_types.mathesar_money
1689+
RETURN NEXT throws_ok(
1690+
format(
1691+
$s$
1692+
SELECT msar.retype_column(%s, 8::smallint, 'numeric'::text, %L::jsonb);
1693+
$s$,
1694+
tab_id::oid,
1695+
cast_options_2
1696+
),
1697+
'22P02',
1698+
'invalid input syntax for type numeric: "$9850000.00"',
1699+
'Retyping a text column with currency symbols to numeric throws an error to avoid data loss during import.'
1700+
);
1701+
END;
1702+
$f$ LANGUAGE plpgsql;
1703+
1704+
16731705
-- msar.add_mathesar_table
16741706

16751707
CREATE OR REPLACE FUNCTION __setup_create_table() RETURNS SETOF TEXT AS $f$
@@ -1957,7 +1989,7 @@ BEGIN
19571989
CREATE TABLE test_schema.col_alters (
19581990
id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
19591991
col1 text NOT NULL,
1960-
col2 numeric DEFAULT 5,
1992+
col2 numeric DEFAULT '5'::numeric,
19611993
"Col sp" text,
19621994
col_opts numeric(5, 3),
19631995
coltim timestamp DEFAULT now()

docs/docs/releases/0.7.0.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# Mathesar 0.7.0
22

3-
!!! question "Want cross-table editing in Mathesar? Talk to us!"
4-
For our next release, we're actively working on the ability to edit data from multiple tables in a single view.
5-
6-
If you're interested, we'd love your input so we're prioritizing the right problems to solve. [Talk to us for 20 min](https://cal.com/mathesar/users), we'll give you a $25 gift card as a thank you.
3+
???+ warning "Upgrade to 0.7.1 strongly recommended"
4+
Mathesar 0.7.0 contains a regression that prevents casting some database types to others. This bug is fixed in [0.7.1](./0.7.1.md).
75

86
## Summary
97

docs/docs/releases/0.7.1.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Mathesar 0.7.1
2+
3+
!!! question "Want cross-table editing in Mathesar? Talk to us!"
4+
For our next release, we're actively working on the ability to edit data from multiple tables in a single view.
5+
6+
If you're interested, we'd love your input so we're prioritizing the right problems to solve. [Talk to us for 20 min](https://cal.com/mathesar/users), we'll give you a $25 gift card as a thank you.
7+
8+
## Summary
9+
10+
Mathesar 0.7.1 fixes a critical bug that prevented casting database column types from one type to another. This bug most impacted CSV imports, particularly when importing data into new tables or when Mathesar's type inference system needed to adjust column types during the import process. The bug could also affect manual column type changes in existing tables.
11+
12+
!!! info ""
13+
This page provides a comprehensive list of all changes in the release.
14+
15+
## Bug fixes
16+
17+
### Fix column type casting regression
18+
19+
A regression introduced in 0.7.0 caused failures when casting columns between certain database types, particularly when converting between numeric and money types. The casting function was incorrectly applying currency-related formatting options (like currency prefixes and suffixes) to numeric columns that don't support them, and was not properly handling cases where cast options were empty or not applicable to the target type.
20+
21+
*Related work:*
22+
23+
[#4961](https://github.com/mathesar-foundation/mathesar/pull/4961 "Typecast bugfix")
24+
25+
## Documentation
26+
27+
- Update the URL to Mathesar's Railway 1-click deployment template [#4967](https://github.com/mathesar-foundation/mathesar/pull/4967 "Fix railway link in docs")
28+
29+
## Upcoming changes in 0.8.0
30+
31+
Mathesar's 0.8.0 release will end official support for PostgreSQL 13 and Python 3.9. We recommend upgrading these dependencies prior to installing 0.8.0 to ensure continued compatibility and support.
32+
33+
While Mathesar is likely to function with older versions, compatibility is no longer tested, and assistance cannot be provided for issues encountered on unsupported versions.
34+
35+
Learn more about our [version support strategy](../administration/version-support.md).
36+
37+
## Upgrading to 0.7.1 {:#upgrading}
38+
39+
### For installations using Docker Compose
40+
41+
If you have a Docker compose installation, run the command below:
42+
43+
```
44+
docker compose -f /etc/mathesar/docker-compose.yml up --pull always -d
45+
```
46+
47+
!!! warning "Your installation directory may be different"
48+
You may need to change `/etc/mathesar/` in the command above if you chose to install Mathesar to a different directory.
49+
50+
### For direct installations of Mathesar on Linux, macOS, or WSL
51+
52+
Mathesar provides an install script that automates both fresh installs and upgrades for standalone (non-Docker) installations.
53+
54+
Follow the steps below to upgrade Mathesar:
55+
56+
57+
1. Enter your installation directory into the box below and press <kbd>Enter</kbd> to personalize this guide:
58+
59+
<input data-input-for="MATHESAR_INSTALL_DIR" aria-label="Your Mathesar installation directory"/>
60+
61+
- Do _not_ include a trailing slash.
62+
- Do _not_ use any variables like `$HOME`.
63+
64+
2. Go to your Mathesar installation directory.
65+
66+
```
67+
cd xMATHESAR_INSTALL_DIRx
68+
```
69+
70+
!!! note
71+
Your installation directory may be different from above if you used a different directory when installing Mathesar.
72+
73+
3. Download and run the install script for 0.7.1
74+
```
75+
curl -sSfL https://github.com/mathesar-foundation/mathesar/releases/download/0.7.1/install.sh -o install.sh
76+
chmod +x install.sh
77+
78+
./install.sh .
79+
```
80+
81+
4. Replace your gunicorn systemd service with a Mathesar systemd service
82+
83+
1. Disable and stop the existing gunicorn service
84+
```
85+
systemctl disable gunicorn.service
86+
systemctl stop gunicorn.service
87+
```
88+
89+
2. Follow the steps in [Run Mathesar as a systemd service](../administration/install-from-scratch.md#run-mathesar-as-a-systemd-service) from the installation guide
90+
91+
3. Remove the gunicorn service file
92+
```
93+
sudo rm /lib/systemd/system/gunicorn.service
94+
```
95+
96+
5. Update your Caddyfile
97+
98+
1. Use the configuration shown in [Install and configure Caddy](../administration//install-from-scratch.md#install-and-configure-caddy) in the installation guide, and update your Caddyfile accordingly
99+
100+
2. Ensure that your domains are specified directly in the first line of the Caddyfile
101+
102+
3. Restart your Caddy service
103+
```
104+
systemctl restart caddy.service
105+
```
106+
107+
!!! tip
108+
**If you're running Mathesar only on localhost and do not want it to run as a service**, you could:
109+
110+
1. Remove the gunicorn and caddy services
111+
1. Start Mathesar manually with:
112+
```
113+
mathesar run
114+
```

docs/mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ nav:
4949
- Overview: api/index.md
5050
- Methods: api/methods.md
5151
- Releases:
52-
- '0.7.0': releases/0.7.0.md
52+
- '0.7.1': releases/0.7.1.md
5353
- Previous releases:
54+
- '0.7.0': releases/0.7.0.md
5455
- '0.6.0': releases/0.6.0.md
5556
- '0.5.0': releases/0.5.0.md
5657
- '0.4.0': releases/0.4.0.md
@@ -170,7 +171,7 @@ markdown_extensions:
170171
permalink: true
171172

172173
extra:
173-
mathesar_version: 0.7.0
174+
mathesar_version: 0.7.1
174175
version:
175176
provider: mike
176177
alias: true

mathesar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
default_app_config = 'mathesar.apps.MathesarConfig'
22

3-
__version__ = "0.7.0"
3+
__version__ = "0.7.1"

0 commit comments

Comments
 (0)