Skip to content

Conversation

@Anish9901
Copy link
Member

@Anish9901 Anish9901 commented Nov 6, 2025

#4821 introduced a regression in which the appropriate cast_options parameter wasn't passed for __msar.build_cast_expr from within msar.set_old_col_default this led to a bug where retyping a column with non-dynamic defaults would result in the following error:

UndefinedFunction: function __msar.build_cast_expr(text, text) does not exist LINE 1: format('SELECT %s', __msar.build_cast_expr(old_default, new_... ^ 
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: format('SELECT %s', __msar.build_cast_expr(old_default, new_type)) CONTEXT: PL/pgSQL function msar.set_old_col_default(regclass,smallint,text,text,boolean,jsonb) line 20 at EXECUTE SQL statement "SELECT msar.set_old_col_default(tab_id, col.attnum, col.old_default, col.new_type, is_default_dynamic, col.cast_options)" PL/pgSQL function msar.alter_columns(oid,jsonb) line 78 at PERFORM

We already had tests to ensure type casting a column with a non-dynamic default value would preserve the default and doesn't error but msar.is_default_possibly_dynamic wrongly classified the non-dynamic default as dynamic which is why we didn't catch the aformentioned bug earlier. I've fixed the test setup so that msar.is_default_possibly_dynamic correctly classifies the defaults.

Another bug that was introduced was related to typecasting numeric or mathesar_money inferred columns to other types during the import preview.

  • Casting numeric(inferred) --> mathesar_money wasn't possible as the cast_options didn't contain curr_pref & curr_suff as the inferred column was numeric.
  • Casting mathesar_money(inferred) --> numeric is still not possible as this is a lossy cast if there are currency symbols in the data.

The added tests shows both of these cases.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@Anish9901 Anish9901 requested a review from mathemancer November 6, 2025 21:04
@Anish9901 Anish9901 added pr-status: review A PR awaiting review priority: urgent Blocks other ongoing work labels Nov 6, 2025
@Anish9901 Anish9901 marked this pull request as ready for review November 6, 2025 21:05
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work.

@mathemancer
Copy link
Contributor

mathemancer commented Nov 7, 2025

@zackkrida I'll leave it to you to figure out where/how to merge this. Specifically, I suppose you should make a branch off of master for 0.7.1 (since we don't want to keep any post-0.7.0 changes in develop right now) and rebase this onto that, then merge back into it?

@mathemancer mathemancer assigned zackkrida and unassigned mathemancer Nov 7, 2025
@zackkrida zackkrida changed the base branch from develop to 0.7.1 November 11, 2025 18:54
@zackkrida zackkrida merged commit 3aba514 into 0.7.1 Nov 11, 2025
18 checks passed
@zackkrida zackkrida deleted the bugfix_typecast branch November 11, 2025 18:58
@zackkrida
Copy link
Member

I cherry-picked @Anish9901's commits and merged to a 0.7.1 branch based off of master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-status: review A PR awaiting review priority: urgent Blocks other ongoing work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants