django-dynamic-models icon indicating copy to clipboard operation
django-dynamic-models copied to clipboard

FieldSchema: support for 'db_column' option

Open pyMan opened this issue 4 years ago • 3 comments

It would be nice if user could specify the db_column option for FieldSchema.

I need uppercase field names and as workaround I have to monkey patch the get_options method to inject the db_column option.

pyMan avatar Apr 09 '21 13:04 pyMan

@pyMan the 0.4 release will include a major change in the way field schema are defined. A class path and a JSON field of kwargs will be used to construct the dynamic model's Field instances.

I believe this should support your use case. The master branch is updated but there are still some things to clean up that I haven't gotten around to yet.

rvinzent avatar Apr 10 '21 18:04 rvinzent

@rvinzent ok thank you. Just afraid of JSONField is not supported by all databases, like mssql.

pyMan avatar Apr 10 '21 21:04 pyMan

@pyMan in the latest versions of Django, JSONField was moved into the core fields. I believe they were able to do this because there is now broad database support in most or all of their supported backends.

I also think the flexibility that the feature will add is a worthwhile trade off because it should enable users to dynamically construct any field that can be constructed using JSON serializable kwargs, even custom fields not defined in core Django.

rvinzent avatar Apr 10 '21 22:04 rvinzent