mathesar icon indicating copy to clipboard operation
mathesar copied to clipboard

Dynamic defaults can be altered

Open mathemancer opened this issue 3 years ago • 7 comments

Description

As noted in this comment by @kgodey on #941 , it's currently possible to alter dynamic default value settings via the API through PATCH requests. This is a problem, since if this alteration is made in error, it's not possible for the user to recover (since we don't have the functionality allowing creation of dynamic defaults for columns).

Expected behavior

It should be impossible to change the default generator of a column via the API, until we have functionality that would enable the user to recover from doing so in error.

To Reproduce

Give a PATCH request that to the appropriate columns endpoint that alters the default value of the id column:

{
    "default": {
        "value": 3
    }
}

mathemancer avatar Jan 06 '22 07:01 mathemancer

@mathemancer I don't think this should be specific to the id column, we should not allow static defaults for any column with a unique or primary key constraint.

I don't think we need any specific behavior for the id column, it's fine if users change the name or other attributes.

kgodey avatar Jan 06 '22 15:01 kgodey

Okay, I'll alter this issue accordingly.

mathemancer avatar Jan 06 '22 15:01 mathemancer

This issue has not been updated in 90 days and is being marked as stale.

github-actions[bot] avatar Mar 15 '23 21:03 github-actions[bot]

Hi, @mathemancer, @kgodey, it is currently possible to alter dynamic default value settings via the API through PATCH requests, even for the primary key column, where dynamic default is necessary.

And, after adding a record to the table, the error says The requested insert violates a uniqueness constraint, therefore breaking the insertion functionality.

image

So, our task is to

  • Restrict the PATCH request such that it can't alter the dynamic default of a column? OR
  • Restrict the PATCH request such that it can't alter the dynamic default of a column which has a uniqueness constraint?

Also, can I be assigned to this issue?

Aritra8438 avatar Apr 04 '23 05:04 Aritra8438

Restrict the PATCH request such that it can't alter the dynamic default of a column?

This is what we should do.

kgodey avatar Apr 12 '23 13:04 kgodey

Unassigning due to inactivity

seancolsen avatar Nov 01 '23 18:11 seancolsen

Added needs: troubleshooting since I can't currently reproduce it with the method in the description, but I also don't remember ever solving this bug. Thus, we need to investigate to determine whether this is still occurring or not.

mathemancer avatar Jan 04 '24 15:01 mathemancer