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

Extend set of forbidden fields to include keywords from various database backends

Open Cindy0113 opened this issue 6 years ago • 1 comments

Issue location: /dynamic_models/models.py:254 That is:

class ModelFieldSchema(GenericModel, GenericField): objects = ModelFieldSchemaManager() null = models.BooleanField(default=False) # issue1 unique = models.BooleanField(default=False) # issue2 max_length = models.PositiveIntegerField(null=True)

Problem description:

'null' and 'unique' are keywords in mysql grammar. In our strict DBA system, 'null' and 'unique' are forbidden to be column names.

Suggestion: code to be modified as follows.

class ModelFieldSchema(GenericModel, GenericField): objects = ModelFieldSchemaManager() null = models.BooleanField(default=False, db_column='is_null') # issue1 unique = models.BooleanField(default=False, db_column='is_unique') # issue2 max_length = models.PositiveIntegerField(null=True)

Cindy0113 avatar Nov 08 '19 10:11 Cindy0113

@Cindy0113 Finally following up on this...

I was thinking about programmatically calling into Django's system checks framework to perform many other checks on model errors and warnings. Does this handle your use case?

rvinzent avatar Dec 21 '20 23:12 rvinzent