Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
0cbb6ac0
Kaydet (Commit)
0cbb6ac0
authored
Eyl 09, 2017
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24928 -- Added introspection support for PostgreSQL JSONField
Thanks Adam Johnson and Tim Graham for the reviews.
üst
ffbee67f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
+38
-3
apps.py
django/contrib/postgres/apps.py
+6
-2
django-admin.txt
docs/ref/django-admin.txt
+3
-1
2.0.txt
docs/releases/2.0.txt
+3
-0
test_introspection.py
tests/postgres_tests/test_introspection.py
+26
-0
No files found.
django/contrib/postgres/apps.py
Dosyayı görüntüle @
0cbb6ac0
...
...
@@ -15,8 +15,12 @@ class PostgresConfig(AppConfig):
def
ready
(
self
):
# Connections may already exist before we are called.
for
conn
in
connections
.
all
():
if
conn
.
connection
is
not
None
:
register_type_handlers
(
conn
)
if
conn
.
vendor
==
'postgresql'
:
conn
.
introspection
.
data_types_reverse
.
update
({
3802
:
'django.contrib.postgresql.fields.JSONField'
,
})
if
conn
.
connection
is
not
None
:
register_type_handlers
(
conn
)
connection_created
.
connect
(
register_type_handlers
)
CharField
.
register_lookup
(
Unaccent
)
TextField
.
register_lookup
(
Unaccent
)
...
...
docs/ref/django-admin.txt
Dosyayı görüntüle @
0cbb6ac0
...
...
@@ -366,7 +366,9 @@ output:
* If ``inspectdb`` cannot map a column's type to a model field type, it'll
use ``TextField`` and will insert the Python comment
``'This field type is a guess.'`` next to the field in the generated
model.
model. The recognized fields may depend on apps listed in
:setting:`INSTALLED_APPS`. For example, :mod:`django.contrib.postgres` adds
recognition for several PostgreSQL-specific field types.
* If the database column name is a Python reserved word (such as
``'pass'``, ``'class'`` or ``'for'``), ``inspectdb`` will append
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
0cbb6ac0
...
...
@@ -123,6 +123,9 @@ Minor features
operation installs the ``btree_gist`` extension to add support for operator
classes that aren't built-in.
* :djadmin:`inspectdb` can now introspect ``JSONField``
(``django.contrib.postgres`` must be in ``INSTALLED_APPS``).
:mod:`django.contrib.redirects`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/postgres_tests/test_introspection.py
0 → 100644
Dosyayı görüntüle @
0cbb6ac0
from
io
import
StringIO
from
django.core.management
import
call_command
from
django.test.utils
import
modify_settings
from
.
import
PostgreSQLTestCase
@modify_settings
(
INSTALLED_APPS
=
{
'append'
:
'django.contrib.postgres'
})
class
InspectDBTests
(
PostgreSQLTestCase
):
def
assertFieldsInModel
(
self
,
model
,
field_outputs
):
out
=
StringIO
()
call_command
(
'inspectdb'
,
table_name_filter
=
lambda
tn
:
tn
.
startswith
(
model
),
stdout
=
out
,
)
output
=
out
.
getvalue
()
for
field_output
in
field_outputs
:
self
.
assertIn
(
field_output
,
output
)
def
test_json_field
(
self
):
self
.
assertFieldsInModel
(
'postgres_tests_jsonmodel'
,
[
'field = django.contrib.postgresql.fields.JSONField(blank=True, null=True)'
],
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment