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
38e24d68
Kaydet (Commit)
38e24d68
authored
Ara 05, 2013
tarafından
pegler
Kaydeden (comit)
Simon Charette
Ara 06, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21554 -- Incorrect SQL generated when using multiple inheritance.
üst
b63acdfe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
7 deletions
+35
-7
compiler.py
django/db/models/sql/compiler.py
+13
-6
models.py
tests/model_inheritance_regress/models.py
+14
-0
tests.py
tests/model_inheritance_regress/tests.py
+8
-1
No files found.
django/db/models/sql/compiler.py
Dosyayı görüntüle @
38e24d68
...
@@ -284,25 +284,32 @@ class SQLCompiler(object):
...
@@ -284,25 +284,32 @@ class SQLCompiler(object):
continue
continue
alias
=
self
.
query
.
join_parent_model
(
opts
,
model
,
start_alias
,
alias
=
self
.
query
.
join_parent_model
(
opts
,
model
,
start_alias
,
seen_models
)
seen_models
)
column
=
field
.
column
for
seen_model
,
seen_alias
in
seen_models
.
items
():
if
seen_model
and
seen_alias
==
alias
:
ancestor_link
=
seen_model
.
_meta
.
get_ancestor_link
(
model
)
if
ancestor_link
:
column
=
ancestor_link
.
column
break
table
=
self
.
query
.
alias_map
[
alias
]
.
table_name
table
=
self
.
query
.
alias_map
[
alias
]
.
table_name
if
table
in
only_load
and
field
.
column
not
in
only_load
[
table
]:
if
table
in
only_load
and
column
not
in
only_load
[
table
]:
continue
continue
if
as_pairs
:
if
as_pairs
:
result
.
append
((
alias
,
field
.
column
))
result
.
append
((
alias
,
column
))
aliases
.
add
(
alias
)
aliases
.
add
(
alias
)
continue
continue
if
with_aliases
and
field
.
column
in
col_aliases
:
if
with_aliases
and
column
in
col_aliases
:
c_alias
=
'Col
%
d'
%
len
(
col_aliases
)
c_alias
=
'Col
%
d'
%
len
(
col_aliases
)
result
.
append
(
'
%
s.
%
s AS
%
s'
%
(
qn
(
alias
),
result
.
append
(
'
%
s.
%
s AS
%
s'
%
(
qn
(
alias
),
qn2
(
field
.
column
),
c_alias
))
qn2
(
column
),
c_alias
))
col_aliases
.
add
(
c_alias
)
col_aliases
.
add
(
c_alias
)
aliases
.
add
(
c_alias
)
aliases
.
add
(
c_alias
)
else
:
else
:
r
=
'
%
s.
%
s'
%
(
qn
(
alias
),
qn2
(
field
.
column
))
r
=
'
%
s.
%
s'
%
(
qn
(
alias
),
qn2
(
column
))
result
.
append
(
r
)
result
.
append
(
r
)
aliases
.
add
(
r
)
aliases
.
add
(
r
)
if
with_aliases
:
if
with_aliases
:
col_aliases
.
add
(
field
.
column
)
col_aliases
.
add
(
column
)
return
result
,
aliases
return
result
,
aliases
def
get_distinct
(
self
):
def
get_distinct
(
self
):
...
...
tests/model_inheritance_regress/models.py
Dosyayı görüntüle @
38e24d68
...
@@ -233,3 +233,17 @@ class User(models.Model):
...
@@ -233,3 +233,17 @@ class User(models.Model):
class
Profile
(
User
):
class
Profile
(
User
):
profile_id
=
models
.
AutoField
(
primary_key
=
True
)
profile_id
=
models
.
AutoField
(
primary_key
=
True
)
extra
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
)
extra
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
)
# Check concrete + concrete -> concrete -> concrete
class
Politician
(
models
.
Model
):
politician_id
=
models
.
AutoField
(
primary_key
=
True
)
title
=
models
.
CharField
(
max_length
=
50
)
class
Congressman
(
Person
,
Politician
):
state
=
models
.
CharField
(
max_length
=
2
)
class
Senator
(
Congressman
):
pass
tests/model_inheritance_regress/tests.py
Dosyayı görüntüle @
38e24d68
...
@@ -15,7 +15,7 @@ from .models import (Place, Restaurant, ItalianRestaurant, ParkingLot,
...
@@ -15,7 +15,7 @@ from .models import (Place, Restaurant, ItalianRestaurant, ParkingLot,
SelfRefChild
,
ArticleWithAuthor
,
M2MChild
,
QualityControl
,
DerivedM
,
SelfRefChild
,
ArticleWithAuthor
,
M2MChild
,
QualityControl
,
DerivedM
,
Person
,
BirthdayParty
,
BachelorParty
,
MessyBachelorParty
,
Person
,
BirthdayParty
,
BachelorParty
,
MessyBachelorParty
,
InternalCertificationAudit
,
BusStation
,
TrainStation
,
User
,
Profile
,
InternalCertificationAudit
,
BusStation
,
TrainStation
,
User
,
Profile
,
ParkingLot4A
,
ParkingLot4B
)
ParkingLot4A
,
ParkingLot4B
,
Senator
)
class
ModelInheritanceTest
(
TestCase
):
class
ModelInheritanceTest
(
TestCase
):
...
@@ -455,3 +455,10 @@ class ModelInheritanceTest(TestCase):
...
@@ -455,3 +455,10 @@ class ModelInheritanceTest(TestCase):
# used in the qs and top contains direct pointer to the bottom model.
# used in the qs and top contains direct pointer to the bottom model.
qs
=
ItalianRestaurant
.
objects
.
values_list
(
'serves_gnocchi'
)
.
filter
(
name
=
'foo'
)
qs
=
ItalianRestaurant
.
objects
.
values_list
(
'serves_gnocchi'
)
.
filter
(
name
=
'foo'
)
self
.
assertEqual
(
str
(
qs
.
query
)
.
count
(
'JOIN'
),
1
)
self
.
assertEqual
(
str
(
qs
.
query
)
.
count
(
'JOIN'
),
1
)
def
test_issue_21554
(
self
):
senator
=
Senator
.
objects
.
create
(
name
=
'John Doe'
,
title
=
'X'
,
state
=
'Y'
)
Senator
.
objects
.
get
(
pk
=
senator
.
pk
)
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