Opened 13 years ago
Last modified 2 years ago
#18468 closed New feature
Add the ability to define comments in table / columns — at Version 20
Reported by: | Marc Rechté | Owned by: | KimSoungRyoul |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | niwi@…, Ivan Chernoff | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hello,
That would be nice if it was possible to include comment on table / columns at creation time with the syncdb manage.py option.
....
....
new proposal (kimsoungryoul : 2020.03.23)
We will develop the code such as below
class AModel(models.Model): aaa = model.CharField(help_text="i am help_text", db_column_comment="i am db_comment",~~~) class Meta: db_table = "a_model_example_name" db_table_comment ="this is a_model comment ~~~~"
default settings ENABLE_DB_COMMENT_WITH_HELP_TEXT = False
if it's True
help_text is used for db_column_comment
Change History (19)
comment:2 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is a duplicate of #13867, which lingered in DDN for two years until I wontfix'd it.
The only argument I've seen is "it'd be nice if...". But I'm against adding features to Django just because we can; there must be a use case.
Could you start a thread on the mailing-list, as recommended in the contributing guide, to see if there is support for this idea?
If there's a good explanation of why you need this, I can reconsider my decision.
comment:3 by , 12 years ago
I understand your opinion! In any case, I'll write an email to the list which I think is useful.
Thanks!
comment:4 by , 12 years ago
I assume that most databases have comment on fields / tables feature not just because it is nice. Accessing Django created tables from another tool (for instance pgAdmin) would just make the system more productive. Personally I never create SQL tables without proper comments in the database itself.
comment:5 by , 12 years ago
The reasons given on #13867 still stand — Django is not aiming to provide a wrapper for every SQL feature. For example, it also doesn't provide an easy way to create stored procedures, functions or views, but you can always execute the SQL manually to add these, or could add some additional Python code that executed the SQL — for example using a South migration — if you want to ensure it always happens.
In addition, if the audience of these comments is people administering the database without reading the Python source code, it doesn't make sense for these comments to be taking up space in the Python code, which has its own way of adding comments (docstrings and comment lines), which are targeted at programmers not DB admins.
comment:6 by , 9 years ago
Resolution: | duplicate |
---|---|
Status: | closed → new |
Now that migration is built in Django, which can be used to create and administer the database, I again request this feature to be added. Thanks.
comment:7 by , 9 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Summary: | Define COMMENT in table / colomns → Add the ability to define comments in table / columns |
Type: | Uncategorized → New feature |
The correct way to reopen a ticket closed as "wontfix" is to start a discussion on the DevelopersMailingList. If there is consensus there to add the feature, then we reopen the ticket.
follow-up: 13 comment:8 by , 7 years ago
Cc: | added |
---|---|
Has patch: | unset |
Resolution: | duplicate |
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
Version: | 1.4 → master |
After discussion on mailing list, the feature is good and can be added. (https://groups.google.com/forum/?nomobile=true#!topic/django-developers/guVTzO3RhUs)
I'll prepare patch for review.
follow-up: 10 comment:9 by , 7 years ago
I guess the model field option could be called db_column_comment
. I closed #28407 (introspecting column comments) as a duplicate since that should be implemented as part of this.
comment:10 by , 7 years ago
Replying to Tim Graham:
I guess the model field option could be called
db_column_comment
. I closed #28407 (introspecting column comments) as a duplicate since that should be implemented as part of this.
I think that we don't need new param, because comment
for django admin may be useful to store in database. But I can't decide on implementation, can you give me an advice?
Postgres and oracle have a syntax like comment on {table}.{column}
for storing comments, so this needs to be done after table/column creation, so there are two ways:
- Add it to post migrate signal, as for content types. But I can implement it as a third-party lib
- Add this SQL after database creation in schema.py
Which way is better?
comment:12 by , 7 years ago
I'm not sure what you mean by "comment for django admin". There isn't an existing option with that name.
As for the implementation, the second approach sounds better.
follow-up: 14 comment:13 by , 5 years ago
Replying to Ivan Chernoff:
After discussion on mailing list, the feature is good and can be added. (https://groups.google.com/forum/?nomobile=true#!topic/django-developers/guVTzO3RhUs)
I'll prepare patch for review.
Any news on this patch? It looks like there is a green light for one, and Tim already answered about the preferable approach. Do you need any help on making this hapen? It would be a fantastic feature for Django!
comment:14 by , 5 years ago
Replying to Rodrigo Silva:
Replying to Ivan Chernoff:
After discussion on mailing list, the feature is good and can be added. (https://groups.google.com/forum/?nomobile=true#!topic/django-developers/guVTzO3RhUs)
I'll prepare patch for review.
Any news on this patch? It looks like there is a green light for one, and Tim already answered about the preferable approach. Do you need any help on making this hapen? It would be a fantastic feature for Django!
I've a small library based on contenttype design: on post-migrate it copies all comments to database (PostgreSQL only).
https://github.com/vanadium23/django-db-comments
comment:15 by , 5 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
Needs tests: | set |
Owner: | changed from | to
Patch needs improvement: | set |
Status: | new → assigned |
comment:16 by , 5 years ago
Description: | modified (diff) |
---|
i assign it to me
i will close this pullRequest caused by imperfection
https://github.com/django/django/pull/12605
I will bring a new PullRequest as soon as possible.
in at least a week
comment:17 by , 5 years ago
Description: | modified (diff) |
---|
comment:18 by , 5 years ago
Description: | modified (diff) |
---|
comment:19 by , 5 years ago
Description: | modified (diff) |
---|
comment:20 by , 5 years ago
Description: | modified (diff) |
---|
Initial implementation for postgresql_psycopg2 backend: https://github.com/niwibe/django/compare/issue_18468
Is only implemented the table comment sql.
If accepted as a new feature, would be nice to make design decisions. Today I put the comment for table in class "Meta", another option is to use the first line of the model docstrings.
For fields, is more simple, just add an optional parameter "comment" at the Field.