Re: [Django] #30476: Add detection for PostgreSQL json field, aside from the already existing detection for jsonb field, using inspectdb

2019-05-14 Thread Django
#30476: Add detection for PostgreSQL json field, aside from the already existing
detection for jsonb field, using inspectdb
-+-
 Reporter:  Héctor Pablos|Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  2.2
 Severity:  Normal   |   Resolution:
 Keywords:  inspectdb,   | Triage Stage:
  JSONField, json, jsonb |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Simon Charette):

 There's enough significant differences between `json` and `jsonb` types
 which makes me believe this is not a good idea.

 For example, [https://www.postgresql.org/docs/9.4/datatype-json.html
 containment operators it not supported] on `json` columns while they are
 on `jsonb` ones which breaks the `__contains`
 [https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/#std
 :fieldlookup-hstorefield.contains operator].

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.f24186139708728077fbbfd690a026c4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30476: Add detection for PostgreSQL json field, aside from the already existing detection for jsonb field, using inspectdb

2019-05-14 Thread Django
#30476: Add detection for PostgreSQL json field, aside from the already existing
detection for jsonb field, using inspectdb
-+-
 Reporter:  Héctor Pablos|Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  2.2
 Severity:  Normal   |   Resolution:
 Keywords:  inspectdb,   | Triage Stage:
  JSONField, json, jsonb |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Héctor Pablos:

Old description:

> Right now, the {{{inspectdb}}} command, when the
> {{{django.contrib.postgres}}} app is added to {{{INSTALLED_APPS}}} in the
> settings, is able to detect {{{jsonb}}} fields and generate a model with
> the right {{{django.contrib.postgres.fields.JSONField}}}, but that's not
> the case for simple {{json}} fields.
>
> [https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/#django.contrib.postgres.fields.JSONField
> The documentation] states that the {{{JSONField}}} uses internally a
> PostgreSQL {{{jsonb}}} field, but I wonder if normal {{{json}}} fields
> could also be detected as a {{{JSONField}}}, as they can perfectly work
> for unmanaged models.
>

> I'm happy to do a patch for this if it's considered necessary, adding an
> additional key to the ones provided by the {{{contrib.postgres}}} module
> inside the
> [https://github.com/django/django/blob/2.2/django/contrib/postgres/apps.py#L49
> data_types_reverse dict] with the following information:
>
> {{{
> 114:  'django.contrib.postgres.fields.JSONField',
> }}}
>
> And the documentation and tests considered being necessary.
>
> The id 114 is the OID of the {{{json}}} data type in PostgreSQL, at least
> in its 11.1 version. You can check this by executing the following query:
>
> {{{#!sql
> SELECT oid, typname
> FROM pg_catalog.pg_type
> WHERE typname='json';
> }}}
>
> Also happy to check other database versions if needed.

New description:

 Right now, the {{{inspectdb}}} command, when the
 {{{django.contrib.postgres}}} app is added to {{{INSTALLED_APPS}}} in the
 settings, is able to detect {{{jsonb}}} fields and generate a model with
 the right {{{django.contrib.postgres.fields.JSONField}}}, but that's not
 the case for simple {{{json}}} fields.

 
[https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/#django.contrib.postgres.fields.JSONField
 The documentation] states that the {{{JSONField}}} uses internally a
 PostgreSQL {{{jsonb}}} field, but I wonder if normal {{{json}}} fields
 could also be detected as a {{{JSONField}}}, as they can perfectly work
 for unmanaged models.


 I'm happy to do a patch for this if it's considered necessary, adding an
 additional key to the ones provided by the {{{contrib.postgres}}} module
 inside the
 [https://github.com/django/django/blob/2.2/django/contrib/postgres/apps.py#L49
 data_types_reverse dict] with the following information:

 {{{
 114:  'django.contrib.postgres.fields.JSONField',
 }}}

 And the documentation and tests considered being necessary.

 The id 114 is the OID of the {{{json}}} data type in PostgreSQL, at least
 in its 11.1 version. You can check this by executing the following query:

 {{{#!sql
 SELECT oid, typname
 FROM pg_catalog.pg_type
 WHERE typname='json';
 }}}

 Also happy to check other database versions if needed.

--

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c402f2a4e014c242f11cf49c244df092%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #30476: Add detection for PostgreSQL json field, aside from the already existing detection for jsonb field, using inspectdb

2019-05-14 Thread Django
#30476: Add detection for PostgreSQL json field, aside from the already existing
detection for jsonb field, using inspectdb
-+-
   Reporter:  Héctor |  Owner:  (none)
  Pablos |
   Type:  New| Status:  new
  feature|
  Component: |Version:  2.2
  contrib.postgres   |   Keywords:  inspectdb,
   Severity:  Normal |  JSONField, json, jsonb
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 Right now, the {{{inspectdb}}} command, when the
 {{{django.contrib.postgres}}} app is added to {{{INSTALLED_APPS}}} in the
 settings, is able to detect {{{jsonb}}} fields and generate a model with
 the right {{{django.contrib.postgres.fields.JSONField}}}, but that's not
 the case for simple {{json}} fields.

 
[https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/#django.contrib.postgres.fields.JSONField
 The documentation] states that the {{{JSONField}}} uses internally a
 PostgreSQL {{{jsonb}}} field, but I wonder if normal {{{json}}} fields
 could also be detected as a {{{JSONField}}}, as they can perfectly work
 for unmanaged models.


 I'm happy to do a patch for this if it's considered necessary, adding an
 additional key to the ones provided by the {{{contrib.postgres}}} module
 inside the
 [https://github.com/django/django/blob/2.2/django/contrib/postgres/apps.py#L49
 data_types_reverse dict] with the following information:

 {{{
 114:  'django.contrib.postgres.fields.JSONField',
 }}}

 And the documentation and tests considered being necessary.

 The id 114 is the OID of the {{{json}}} data type in PostgreSQL, at least
 in its 11.1 version. You can check this by executing the following query:

 {{{#!sql
 SELECT oid, typname
 FROM pg_catalog.pg_type
 WHERE typname='json';
 }}}

 Also happy to check other database versions if needed.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.57cac60a5b8f918dd67a2cd94e127988%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.