New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #18468 -- Added support for comments on columns and tables. #14463
Fixed #18468 -- Added support for comments on columns and tables. #14463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Very exciting to see the feature almost ready. In addition to the specific comments on specific lines, this PR also needs:
- Test coverage.
- An entry added to the version 4.0 release notes
@KimSoungRyoul I would be happy to work with you on any / all of these changes. If you'd like me to put together a PR on your branch to incorporate the recommended changes below, and to include some unit tests and the release note update, please let me know and I'd be happy to put that together this week for you to review / accept / update this PR with.
thank you for your feedback 😄 I will add testcase for this feature and reflect your feedback until this weekend |
Hi @jchubber |
1a1e4d5
to
f81acbf
Compare
@KimSoungRyoul I do not have enough familiarity with migration testing either. I'll write a request into the Quick question: Other than the testing, is there anything else you know needs to be done before this ticket is done? It looks to me like you already reflected every piece of feedback I gave ✅ :) |
f81acbf
to
8192ba0
Compare
thank you for your feedback , yes I already reflected every piece of feedback. and I will do rollback 1 commit and force push which contained failed useless testcase
|
@KimSoungRyoul You posted to django-developers and I posted to Django Core Mentorship (link to thread). It looks like the feedback from both groups is consistent: extending |
659378c
to
2a5f67e
Compare
I haven't done much make testcase yet. but soon will be done ... by the way Can you "Resolve Conversation" that has already been reflected? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like roughly the right approach to me but I don't know the schema generation code well enough to make much comment otherwise.
For the tests, I'm not sure the test you have is the best way to do it. I think maybe having a look at tests/schema/tests.py
and adding something there would be more appropriate, but I'm not sure. Probably it would be good to test the system checks work as well, looking at tests/invalid_models_tests/test_ordinary_fields.py
may help. Since you've added introspection code you'll also need to test that, maybe in tests/inspectdb/tests.py
.
@knyghty thank you for your feedback. @jchubber
Is there anything else to think about besides the feedback you suggested? |
What happens if you add I'm not sure if any other fields will have this issue. |
I didn't consider about that. if self.db_comment:
warnings.append(
checks.Warning(
'db_comment has no effect on ManyToManyField.',
obj=self,
id='fields.W3xx',
)
) I will add this and consider what happens when Thanks |
(👍 awesome work @KimSoungRyoul and great points @knyghty !) ManyToManyFields: This was a good catch by @knyghty. Django creates an intermediary join table in the db for every ManyToMany field. In theory, we could support db_comments on |
Test Cases:
|
I did an additional review of the Django model docs and found three other situations where db_comment support might get complicated: 1) Unmanaged models:(link to docs). For any model that has... class Meta:
managed = False ...Django will not perform create, modify, or delete operations on the model. That means that db_comments cannot be supported for unmanaged models. I recommend that the docs be updated to state that db_comments are ignored when managed = False. 2) Proxy models:(link to docs). A class Meta:
proxy = True ...then I think perhaps db_comments should not be supported at the table or column-levels. That should be documented in the docs, should trigger a warning (during migration?), and should have a unit test to ensure that if a Django user specifies a db_comment on a proxy model that Django doesn't error. 3) Abstract Base Classes:(link to docs) Django doesn't create tables for Abstract Base Classes, so a table-level db_comment on an Abstract Base Class does NOT make sense. But a field-level (or "column-level") db_comment on an Abstract Base Class' fields DOES make sense because those fields will eventually be created for any of the models that inherit from the Abstract Base Class. So for example, with... from django.db import models
class CommonInfo(models.Model):
name = models.CharField(max_length=100)
age = models.PositiveIntegerField(db_comment="User's age when they registered.")
class Meta:
abstract = True
class Student(CommonInfo):
home_group = models.CharField(max_length=5) ...then a unit test should verify that in the db the |
@KimSoungRyoul I was busy the past 2 weeks, but I have more control over my time for the coming 2 weeks. Is there anything here that I can be helpful with? Writing docs? Working on code for some piece of the items mentioned above 👆? |
I think Logically, it is correct that ManyToManyField does not support |
ddf959a
to
6603361
Compare
Why fail to connect only py3.9-mysql? Is it just a temporary issue? File "/home/jenkins/workspace/pull-requests-bionic/database/mysql_gis/label/bionic-pr/python/python3.9/tests/.env/lib/python3.9/site-packages/MySQLdb/__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/home/jenkins/workspace/pull-requests-bionic/database/mysql_gis/label/bionic-pr/python/python3.9/tests/.env/lib/python3.9/site-packages/MySQLdb/connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
Build step 'Execute shell' marked build as failure |
thanks for your feedback @jchubber
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments, mostly around the docs / grammar. They're all quite subjective.
I think you're right about ManyToManyField, we don't need to add a maintenance burden here. If a user wants to add a comment to the table, this is already supported: they can use a through model or a SQL migration.
@charettes, would you like to take a look? |
Status update: Patch is Ready for Review
Because this patch now meets every requirement on the development checklist, I've updated the status in the Django ticket tracker so that it shows up in the The next step is for anyone except the patch author(s) to review the patch using the patch review checklist and either mark the ticket as |
thanks! |
Hi may I know what more I should do? such as requesting reviews from others or reflecting feedback |
@KimSoungRyoul I'm reviewing the using this patch review checklist. Here's the current status of that checklist:
Changes that remain to be made:
Once these changes are made, I'll mark this "Ready for checkin" and then a committer will have the chance to review and either accept it or send it back for changes. (I'm not a committer) |
Made _alter_column_comment_sql() return only (sql, params) tuple, see django#14463 (comment).
e0f1994
to
0b781c0
Compare
Seen this PR via @felixxm toot 😄 FYI |
As far as I'm aware, basing |
Fine, make sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added introspection of table comments.
e7625e1
to
d60d641
Compare
Added |
I am 65% satisfied with this patch 📈, so we're making progress 🕐. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed edits to tests.
Made _alter_column_comment_sql() return only (sql, params) tuple, see django#14463 (comment).
529081e
to
417288d
Compare
@KimSoungRyoul Thanks for all your efforts 🥇 Welcome aboard ⛵ Thanks y'all for reviews 🌟 It's ready 🚀 |
eef7aec
to
911cf6a
Compare
Thanks to your reviews, the pullrequest was completed well. 😄 |
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz Felisiak for reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
911cf6a
to
78f163a
Compare
@@ -62,7 +63,8 @@ def get_table_list(self, cursor): | |||
WHEN c.relispartition THEN 'p' | |||
WHEN c.relkind IN ('m', 'v') THEN 'v' | |||
ELSE 't' | |||
END | |||
END, | |||
obj_description(c.oid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While looking at CockroachDB support, the following from the PostgreSQL documentation was brought to my attention:
obj_description ( object oid ) → text
Returns the comment for a database object specified by its OID alone.
This is deprecated since there is no guarantee that OIDs are unique
across different system catalogs; therefore, the wrong comment might
be returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 🎯 We should add a catalog name.
more detail description: https://code.djangoproject.com/ticket/18468
Django
Converted to postgres dialect
Converted to mysql dialect
sqlite3
not supported