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
6605ac33
Kaydet (Commit)
6605ac33
authored
Ock 26, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #17158 -- Used a non-ambiguous representation of SQL queries
when a correct representation cannot be obtained.
üst
d18893d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
__init__.py
django/db/backends/__init__.py
+3
-3
tests.py
tests/regressiontests/backends/tests.py
+14
-4
No files found.
django/db/backends/__init__.py
Dosyayı görüntüle @
6605ac33
...
...
@@ -614,11 +614,11 @@ class BaseDatabaseOperations(object):
# Convert params to contain Unicode values.
to_unicode
=
lambda
s
:
force_text
(
s
,
strings_only
=
True
,
errors
=
'replace'
)
if
isinstance
(
params
,
(
list
,
tuple
)):
u_params
=
tuple
(
[
to_unicode
(
val
)
for
val
in
params
]
)
u_params
=
tuple
(
to_unicode
(
val
)
for
val
in
params
)
else
:
u_params
=
dict
(
[(
to_unicode
(
k
),
to_unicode
(
v
))
for
k
,
v
in
params
.
items
()]
)
u_params
=
dict
(
(
to_unicode
(
k
),
to_unicode
(
v
))
for
k
,
v
in
params
.
items
()
)
return
force_text
(
sql
)
%
u_params
return
six
.
text_type
(
"QUERY =
%
r - PARAMS =
%
r"
)
%
(
sql
,
u_params
)
def
last_insert_id
(
self
,
cursor
,
table_name
,
pk_name
):
"""
...
...
tests/regressiontests/backends/tests.py
Dosyayı görüntüle @
6605ac33
...
...
@@ -16,7 +16,7 @@ from django.db.models import fields, Sum, Avg, Variance, StdDev
from
django.db.utils
import
ConnectionHandler
,
DatabaseError
,
load_backend
from
django.test
import
(
TestCase
,
skipUnlessDBFeature
,
skipIfDBFeature
,
TransactionTestCase
)
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
,
str_prefix
from
django.utils
import
six
from
django.utils.six.moves
import
xrange
from
django.utils
import
unittest
...
...
@@ -160,24 +160,34 @@ class DateQuotingTest(TestCase):
self
.
assertEqual
(
len
(
classes
),
1
)
@override_settings
(
DEBUG
=
True
)
class
LastExecutedQueryTest
(
TestCase
):
@override_settings
(
DEBUG
=
True
)
def
test_debug_sql
(
self
):
list
(
models
.
Tag
.
objects
.
filter
(
name
=
"test"
))
sql
=
connection
.
queries
[
-
1
][
'sql'
]
.
lower
()
self
.
assert
True
(
sql
.
startswith
(
"select"
)
)
self
.
assert
In
(
"select"
,
sql
)
self
.
assertIn
(
models
.
Tag
.
_meta
.
db_table
,
sql
)
def
test_query_encoding
(
self
):
"""
Test that last_executed_query() returns an Unicode string
"""
tags
=
models
.
Tag
.
objects
.
extra
(
select
=
{
'föö'
:
1
})
tags
=
models
.
Tag
.
objects
.
extra
(
select
=
{
'föö'
:
1
})
sql
,
params
=
tags
.
query
.
sql_with_params
()
cursor
=
tags
.
query
.
get_compiler
(
'default'
)
.
execute_sql
(
None
)
last_sql
=
cursor
.
db
.
ops
.
last_executed_query
(
cursor
,
sql
,
params
)
self
.
assertTrue
(
isinstance
(
last_sql
,
six
.
text_type
))
@unittest.skipUnless
(
connection
.
vendor
==
'sqlite'
,
"This test is specific to SQLite."
)
def
test_no_interpolation_on_sqlite
(
self
):
# Regression for #17158
# This shouldn't raise an exception
query
=
"SELECT strftime('
%
Y', 'now');"
connection
.
cursor
()
.
execute
(
query
)
self
.
assertEqual
(
connection
.
queries
[
-
1
][
'sql'
],
str_prefix
(
"QUERY =
%(_)
s
\"
SELECT strftime('
%%
Y', 'now');
\"
- PARAMS = ()"
))
class
ParameterHandlingTest
(
TestCase
):
def
test_bad_parameter_count
(
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