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
afc708cf
Unverified
Kaydet (Commit)
afc708cf
authored
Nis 05, 2019
tarafından
Florian Apolloner
Kaydeden (comit)
Mariusz Felisiak
Nis 08, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30330 -- Fixed setting of primary key to None during fast-delete.
Regression in
bc7dd849
.
üst
19fc6376
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
deletion.py
django/db/models/deletion.py
+1
-0
2.2.1.txt
docs/releases/2.2.1.txt
+3
-0
tests.py
tests/delete/tests.py
+9
-0
No files found.
django/db/models/deletion.py
Dosyayı görüntüle @
afc708cf
...
...
@@ -277,6 +277,7 @@ class Collector:
if
self
.
can_fast_delete
(
instance
):
with
transaction
.
mark_for_rollback_on_error
():
count
=
sql
.
DeleteQuery
(
model
)
.
delete_batch
([
instance
.
pk
],
self
.
using
)
setattr
(
instance
,
model
.
_meta
.
pk
.
attname
,
None
)
return
count
,
{
model
.
_meta
.
label
:
count
}
with
transaction
.
atomic
(
using
=
self
.
using
,
savepoint
=
False
):
...
...
docs/releases/2.2.1.txt
Dosyayı görüntüle @
afc708cf
...
...
@@ -22,3 +22,6 @@ Bugfixes
:class:`~django.contrib.postgres.aggregates.ArrayAgg` and
:class:`~django.contrib.postgres.aggregates.StringAgg` when it contains an
expression with params (:ticket:`30332`).
* Fixed a regression in Django 2.2 that caused a single instance fast-delete
to not set the primary key to ``None`` (:ticket:`30330`).
tests/delete/tests.py
Dosyayı görüntüle @
afc708cf
from
math
import
ceil
from
django.db
import
IntegrityError
,
connection
,
models
from
django.db.models.deletion
import
Collector
from
django.db.models.sql.constants
import
GET_ITERATOR_CHUNK_SIZE
from
django.test
import
TestCase
,
skipIfDBFeature
,
skipUnlessDBFeature
...
...
@@ -471,6 +472,14 @@ class FastDeleteTests(TestCase):
self
.
assertEqual
(
User
.
objects
.
count
(),
1
)
self
.
assertTrue
(
User
.
objects
.
filter
(
pk
=
u2
.
pk
)
.
exists
())
def
test_fast_delete_instance_set_pk_none
(
self
):
u
=
User
.
objects
.
create
()
# User can be fast-deleted.
collector
=
Collector
(
using
=
'default'
)
self
.
assertTrue
(
collector
.
can_fast_delete
(
u
))
u
.
delete
()
self
.
assertIsNone
(
u
.
pk
)
def
test_fast_delete_joined_qs
(
self
):
a
=
Avatar
.
objects
.
create
(
desc
=
'a'
)
User
.
objects
.
create
(
avatar
=
a
)
...
...
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