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
d2202ec2
Kaydet (Commit)
d2202ec2
authored
Kas 30, 2014
tarafından
Markus Holtermann
Kaydeden (comit)
Loic Bistuer
Ara 01, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23880 -- Added missing index_together handling for SQLite
üst
88edce2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
schema.py
django/db/backends/sqlite3/schema.py
+19
-1
1.7.2.txt
docs/releases/1.7.2.txt
+2
-0
test_operations.py
tests/migrations/test_operations.py
+2
-4
No files found.
django/db/backends/sqlite3/schema.py
Dosyayı görüntüle @
d2202ec2
...
@@ -43,7 +43,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
...
@@ -43,7 +43,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
else
:
else
:
raise
ValueError
(
"Cannot quote parameter value
%
r of type
%
s"
%
(
value
,
type
(
value
)))
raise
ValueError
(
"Cannot quote parameter value
%
r of type
%
s"
%
(
value
,
type
(
value
)))
def
_remake_table
(
self
,
model
,
create_fields
=
[],
delete_fields
=
[],
alter_fields
=
[],
override_uniques
=
None
):
def
_remake_table
(
self
,
model
,
create_fields
=
[],
delete_fields
=
[],
alter_fields
=
[],
override_uniques
=
None
,
override_indexes
=
None
):
"""
"""
Shortcut to transform a model from old_model into new_model
Shortcut to transform a model from old_model into new_model
"""
"""
...
@@ -110,11 +111,20 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
...
@@ -110,11 +111,20 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
for
unique
in
model
.
_meta
.
unique_together
for
unique
in
model
.
_meta
.
unique_together
]
]
# Work out the new value for index_together, taking renames into
# account
if
override_indexes
is
None
:
override_indexes
=
[
[
rename_mapping
.
get
(
n
,
n
)
for
n
in
index
]
for
index
in
model
.
_meta
.
index_together
]
# Construct a new model for the new state
# Construct a new model for the new state
meta_contents
=
{
meta_contents
=
{
'app_label'
:
model
.
_meta
.
app_label
,
'app_label'
:
model
.
_meta
.
app_label
,
'db_table'
:
model
.
_meta
.
db_table
+
"__new"
,
'db_table'
:
model
.
_meta
.
db_table
+
"__new"
,
'unique_together'
:
override_uniques
,
'unique_together'
:
override_uniques
,
'index_together'
:
override_indexes
,
'apps'
:
apps
,
'apps'
:
apps
,
}
}
meta
=
type
(
"Meta"
,
tuple
(),
meta_contents
)
meta
=
type
(
"Meta"
,
tuple
(),
meta_contents
)
...
@@ -190,6 +200,14 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
...
@@ -190,6 +200,14 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# Alter by remaking table
# Alter by remaking table
self
.
_remake_table
(
model
,
alter_fields
=
[(
old_field
,
new_field
)])
self
.
_remake_table
(
model
,
alter_fields
=
[(
old_field
,
new_field
)])
def
alter_index_together
(
self
,
model
,
old_index_together
,
new_index_together
):
"""
Deals with a model changing its index_together.
Note: The input index_togethers must be doubly-nested, not the single-
nested ["foo", "bar"] format.
"""
self
.
_remake_table
(
model
,
override_indexes
=
new_index_together
)
def
alter_unique_together
(
self
,
model
,
old_unique_together
,
new_unique_together
):
def
alter_unique_together
(
self
,
model
,
old_unique_together
,
new_unique_together
):
"""
"""
Deals with a model changing its unique_together.
Deals with a model changing its unique_together.
...
...
docs/releases/1.7.2.txt
Dosyayı görüntüle @
d2202ec2
...
@@ -89,3 +89,5 @@ Bugfixes
...
@@ -89,3 +89,5 @@ Bugfixes
* Fixed an infinite loop bug for certain cyclic migration dependencies, and made
* Fixed an infinite loop bug for certain cyclic migration dependencies, and made
the error message for cyclic dependencies much more helpful.
the error message for cyclic dependencies much more helpful.
* Added missing ``index_together`` handling for SQLite (:ticket:`23880`).
tests/migrations/test_operations.py
Dosyayı görüntüle @
d2202ec2
...
@@ -1052,16 +1052,14 @@ class OperationTests(OperationTestBase):
...
@@ -1052,16 +1052,14 @@ class OperationTests(OperationTestBase):
cursor
.
execute
(
"INSERT INTO test_rnfl_pony (blue, weight) VALUES (1, 1)"
)
cursor
.
execute
(
"INSERT INTO test_rnfl_pony (blue, weight) VALUES (1, 1)"
)
cursor
.
execute
(
"DELETE FROM test_rnfl_pony"
)
cursor
.
execute
(
"DELETE FROM test_rnfl_pony"
)
# Ensure the index constraint has been ported over
# Ensure the index constraint has been ported over
# TODO: Uncomment assert when #23880 is fixed
self
.
assertIndexExists
(
"test_rnfl_pony"
,
[
"weight"
,
"blue"
])
# self.assertIndexExists("test_rnfl_pony", ["weight", "blue"])
# And test reversal
# And test reversal
with
connection
.
schema_editor
()
as
editor
:
with
connection
.
schema_editor
()
as
editor
:
operation
.
database_backwards
(
"test_rnfl"
,
editor
,
new_state
,
project_state
)
operation
.
database_backwards
(
"test_rnfl"
,
editor
,
new_state
,
project_state
)
self
.
assertColumnExists
(
"test_rnfl_pony"
,
"pink"
)
self
.
assertColumnExists
(
"test_rnfl_pony"
,
"pink"
)
self
.
assertColumnNotExists
(
"test_rnfl_pony"
,
"blue"
)
self
.
assertColumnNotExists
(
"test_rnfl_pony"
,
"blue"
)
# Ensure the index constraint has been reset
# Ensure the index constraint has been reset
# TODO: Uncomment assert when #23880 is fixed
self
.
assertIndexExists
(
"test_rnfl_pony"
,
[
"weight"
,
"pink"
])
# self.assertIndexExists("test_rnfl_pony", ["weight", "pink"])
# And deconstruction
# And deconstruction
definition
=
operation
.
deconstruct
()
definition
=
operation
.
deconstruct
()
self
.
assertEqual
(
definition
[
0
],
"RenameField"
)
self
.
assertEqual
(
definition
[
0
],
"RenameField"
)
...
...
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