-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Refs #24928 -- Added introspection support for PostgreSQL JSONField #9046
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
Conversation
Could maybe be documented in the |
You're right in that people inspecting a legacy db may not know in advance that a contrib.postgres supported field is present. I'm afraid that putting a note inside |
"This field is a guess. It may be supported by contrib or third party apps." ? |
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.
Usually we camel case assertions to match the unittest style. Maybe assertFieldsInModel (considering field_outputs is a list).
django/contrib/postgres/apps.py
Outdated
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 could be indented inside the if conn.vendor
to avoid a redundant check.
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.
Did you meant inside if conn.connection
? We want to update data_types_reverse
whatever conn.connection
is.
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.
if conn.vendor == 'postgresql':
conn.introspection.data_types_reverse.update({
...
if conn.connection is not None:
(register_type_handlers() also checks conn.vendor == 'postgresql'
so that avoids that same check for the non-postgres case)
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.
Ack!
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.
trailing comma
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.
test_jsonfield
looks good to me (since this is InspectDBTests, _introspection seems redundant).
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.
My inclination is to omit this change as part of this commit. For new users, I think it will raise more questions than answers. I think it's probably better to have some more specific instructions in docs/howto/legacy-databases.txt
about it. Considering there's no stable API for it, I'd be surprised if there are any third-party apps that are adding introspection for their fields but if there are some examples, I'd be interested to know about it.
django/contrib/postgres/apps.py
Outdated
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.
chop blank line?
Tentative doc addition. |
docs/ref/django-admin.txt
Outdated
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.
Maybe wait to add the doc until "several" fields are actually supported?
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.
Adding RangeFields support is straightforward, the patch is already in good shape.
docs/ref/django-admin.txt
Outdated
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.
Double the backticks or use
:mod:`django.contrib.postgres`
It merits a release note for
|
Thanks Adam Johnson and Tim Graham for the reviews.
See #9049 for RangeField. |
No description provided.