django-add-default-value icon indicating copy to clipboard operation
django-add-default-value copied to clipboard

Support Raw Default Strings

Open jpulec opened this issue 4 years ago • 1 comments

I've run into a couple scenarios where allowing the use of a raw string to be used as a default would be useful. For example to call an unsupported function, like generate_uuid_v4() or to specify a default for a specific type, i.e. '{}'::jsonb as a default for a JSONB column.

Would it make sense to support passing a 'raw' string that wouldn't be escaped when generating the default expression?

jpulec avatar Jan 26 '21 19:01 jpulec

Hi @jpulec, Interesting suggestion, I like it. It would definitely be useful to have this kind of support somehow.

For the '{}'::jsonb case, a cool solution would be to introspect the models, and determine how to interpret AddDefaultValue.value depending on the Field class that is used for the targeted field :)

David-Wobrock avatar Jan 31 '21 21:01 David-Wobrock