(postgres) defaultValue is not enforced in database #6048
Replies: 3 comments
-
Hey @HarleySalas — we actually do populate default values if an existing document is resaved after having a new We could enforce statically defined default values on the DB-level, but as you said, Payload's Enforcing statically defined default values on the DB level in Postgres would certainly be a good feature request, and wouldn't be hard to do. But I'm not sure that we will be able to get to it in the immediate future. I will convert this to a Discussion and transfer it over to the Payload core repo so that we can track it accordingly as a feature request. How's that? |
Beta Was this translation helpful? Give feedback.
-
Hi @HarleySalas @jmikrut this PR adds #6983 non-function |
Beta Was this translation helpful? Give feedback.
-
I had to do this as a separate PR. #7368 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In my scenario, I'm using a
radio
field, withrequired: true
anddefaultValue: 'myValue'
. I have these things on globals, so they're at the base level of the table, not in any sort of creatable state. (It's a typical "link" field, as in the website example)According to discord user
ritsu0455
, he believes that every field'sdefaultValue
is not enforced at the schema level, so it could create issues for many scenarios.If it cannot be enforced at the database level, as I understand that fields are flexible elements, perhaps you could simply handle scenarios where when an existing document has a field with a defaultValue added, it should at least apply that value when being added.
Beta Was this translation helpful? Give feedback.
All reactions