rvinzent / django-dynamic-models

Dynamic Django models allow users to define, edit, and populate their own database schema.
MIT License
158 stars 47 forks source link

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

Open Cindy0113 opened 5 years ago

Cindy0113 commented 5 years ago

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)

rvinzent commented 3 years ago

@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?