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
f28d29e8
Kaydet (Commit)
f28d29e8
authored
Kas 05, 2016
tarafından
Saulius Žemaitaitis
Kaydeden (comit)
Tim Graham
Kas 06, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27372 -- Fixed introspection of SQLite foreign keys with spaces in DDL.
Thanks samuller for the report and initial patch.
üst
09da1e79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
introspection.py
django/db/backends/sqlite3/introspection.py
+1
-1
tests.py
tests/introspection/tests.py
+13
-11
No files found.
django/db/backends/sqlite3/introspection.py
Dosyayı görüntüle @
f28d29e8
...
...
@@ -132,7 +132,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
if
field_desc
.
startswith
(
"FOREIGN KEY"
):
# Find name of the target FK field
m
=
re
.
match
(
r'FOREIGN KEY\(([^\)]*)\).*'
,
field_desc
,
re
.
I
)
m
=
re
.
match
(
r'FOREIGN KEY\
s*\
(([^\)]*)\).*'
,
field_desc
,
re
.
I
)
field_name
=
m
.
groups
()[
0
]
.
strip
(
'"'
)
else
:
field_name
=
field_desc
.
split
()[
0
]
.
strip
(
'"'
)
...
...
tests/introspection/tests.py
Dosyayı görüntüle @
f28d29e8
...
...
@@ -143,17 +143,19 @@ class IntrospectionTests(TransactionTestCase):
@skipUnless
(
connection
.
vendor
==
'sqlite'
,
"This is an sqlite-specific issue"
)
def
test_get_relations_alt_format
(
self
):
"""With SQLite, foreign keys can be added with different syntaxes."""
with
connection
.
cursor
()
as
cursor
:
cursor
.
fetchone
=
mock
.
Mock
(
return_value
=
[
"CREATE TABLE track(id, art_id INTEGER, FOREIGN KEY(art_id) REFERENCES {}(id));"
.
format
(
Article
.
_meta
.
db_table
)
]
)
relations
=
connection
.
introspection
.
get_relations
(
cursor
,
'mocked_table'
)
self
.
assertEqual
(
relations
,
{
'art_id'
:
(
'id'
,
Article
.
_meta
.
db_table
)})
"""
With SQLite, foreign keys can be added with different syntaxes and
formatting.
"""
create_table_statements
=
[
"CREATE TABLE track(id, art_id INTEGER, FOREIGN KEY(art_id) REFERENCES {}(id));"
,
"CREATE TABLE track(id, art_id INTEGER, FOREIGN KEY (art_id) REFERENCES {}(id));"
]
for
statement
in
create_table_statements
:
with
connection
.
cursor
()
as
cursor
:
cursor
.
fetchone
=
mock
.
Mock
(
return_value
=
[
statement
.
format
(
Article
.
_meta
.
db_table
)])
relations
=
connection
.
introspection
.
get_relations
(
cursor
,
'mocked_table'
)
self
.
assertEqual
(
relations
,
{
'art_id'
:
(
'id'
,
Article
.
_meta
.
db_table
)})
@skipUnlessDBFeature
(
'can_introspect_foreign_keys'
)
def
test_get_key_columns
(
self
):
...
...
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