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
dad8434d
Kaydet (Commit)
dad8434d
authored
Agu 08, 2015
tarafından
Caio Ariede
Kaydeden (comit)
Tim Graham
Agu 15, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25180 -- Prevented varchar_patterns_ops and text_patterns_ops indexes for ArrayField.
üst
7a40fef1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
0 deletions
+61
-0
schema.py
django/db/backends/postgresql/schema.py
+5
-0
1.8.4.txt
docs/releases/1.8.4.txt
+3
-0
0001_initial.py
tests/postgres_tests/array_index_migrations/0001_initial.py
+26
-0
__init__.py
tests/postgres_tests/array_index_migrations/__init__.py
+0
-0
test_array.py
tests/postgres_tests/test_array.py
+27
-0
No files found.
django/db/backends/postgresql/schema.py
Dosyayı görüntüle @
dad8434d
...
...
@@ -29,6 +29,11 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# a second index that specifies their operator class, which is
# needed when performing correct LIKE queries outside the
# C locale. See #12234.
#
# The same doesn't apply to array fields such as varchar[size]
# and text[size], so skip them.
if
'['
in
db_type
:
continue
if
db_type
.
startswith
(
'varchar'
):
output
.
append
(
self
.
_create_index_sql
(
model
,
[
field
],
suffix
=
'_like'
,
sql
=
self
.
sql_create_varchar_index
))
...
...
docs/releases/1.8.4.txt
Dosyayı görüntüle @
dad8434d
...
...
@@ -31,3 +31,6 @@ Bugfixes
* Moved the :ref:`unsaved model instance assignment data loss check
<unsaved-model-instance-check-18>` to ``Model.save()`` to allow easier usage
of in-memory models (:ticket:`25160`).
* Prevented ``varchar_patterns_ops`` and ``text_patterns_ops`` indexes for
``ArrayField`` (:ticket:`25180`).
tests/postgres_tests/array_index_migrations/0001_initial.py
0 → 100644
Dosyayı görüntüle @
dad8434d
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
django.contrib.postgres.fields
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'CharTextArrayIndexModel'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'char'
,
django
.
contrib
.
postgres
.
fields
.
ArrayField
(
models
.
CharField
(
max_length
=
10
),
db_index
=
True
,
size
=
100
)),
(
'char2'
,
models
.
CharField
(
max_length
=
11
,
db_index
=
True
)),
(
'text'
,
django
.
contrib
.
postgres
.
fields
.
ArrayField
(
models
.
TextField
(),
db_index
=
True
)),
],
options
=
{
},
bases
=
(
models
.
Model
,),
),
]
tests/postgres_tests/array_index_migrations/__init__.py
0 → 100644
Dosyayı görüntüle @
dad8434d
tests/postgres_tests/test_array.py
Dosyayı görüntüle @
dad8434d
...
...
@@ -312,6 +312,33 @@ class TestMigrations(TransactionTestCase):
with
connection
.
cursor
()
as
cursor
:
self
.
assertNotIn
(
table_name
,
connection
.
introspection
.
table_names
(
cursor
))
@override_settings
(
MIGRATION_MODULES
=
{
"postgres_tests"
:
"postgres_tests.array_index_migrations"
,
})
def
test_adding_arrayfield_with_index
(
self
):
"""
ArrayField shouldn't have varchar_patterns_ops or text_patterns_ops indexes.
"""
table_name
=
'postgres_tests_chartextarrayindexmodel'
call_command
(
'migrate'
,
'postgres_tests'
,
verbosity
=
0
)
with
connection
.
cursor
()
as
cursor
:
like_constraint_field_names
=
[
c
.
rsplit
(
'_'
,
2
)[
0
][
len
(
table_name
)
+
1
:]
for
c
in
connection
.
introspection
.
get_constraints
(
cursor
,
table_name
)
if
c
.
endswith
(
'_like'
)
]
# Only the CharField should have a LIKE index.
self
.
assertEqual
(
like_constraint_field_names
,
[
'char2'
])
with
connection
.
cursor
()
as
cursor
:
indexes
=
connection
.
introspection
.
get_indexes
(
cursor
,
table_name
)
# All fields should have regular indexes.
self
.
assertIn
(
'char'
,
indexes
)
self
.
assertIn
(
'char2'
,
indexes
)
self
.
assertIn
(
'text'
,
indexes
)
call_command
(
'migrate'
,
'postgres_tests'
,
'zero'
,
verbosity
=
0
)
with
connection
.
cursor
()
as
cursor
:
self
.
assertNotIn
(
table_name
,
connection
.
introspection
.
table_names
(
cursor
))
class
TestSerialization
(
PostgreSQLTestCase
):
test_data
=
'[{"fields": {"field": "[
\\
"1
\\
",
\\
"2
\\
"]"}, "model": "postgres_tests.integerarraymodel", "pk": null}]'
...
...
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