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
e9ef9776
Kaydet (Commit)
e9ef9776
authored
Haz 13, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18461 -- Ensured that last_executed_query returns Unicode
Thanks Anssi Kääriäinen for the review.
üst
a7ef802f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
base.py
django/db/backends/mysql/base.py
+1
-1
operations.py
django/db/backends/postgresql_psycopg2/operations.py
+3
-1
tests.py
tests/regressiontests/backends/tests.py
+15
-9
No files found.
django/db/backends/mysql/base.py
Dosyayı görüntüle @
e9ef9776
...
...
@@ -238,7 +238,7 @@ class DatabaseOperations(BaseDatabaseOperations):
# With MySQLdb, cursor objects have an (undocumented) "_last_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
return
cursor
.
_last_executed
return
cursor
.
_last_executed
.
decode
(
'utf-8'
)
def
no_limit_value
(
self
):
# 2**64 - 1, as recommended by the MySQL documentation
...
...
django/db/backends/postgresql_psycopg2/operations.py
Dosyayı görüntüle @
e9ef9776
...
...
@@ -193,7 +193,9 @@ class DatabaseOperations(BaseDatabaseOperations):
def
last_executed_query
(
self
,
cursor
,
sql
,
params
):
# http://initd.org/psycopg/docs/cursor.html#cursor.query
# The query attribute is a Psycopg extension to the DB API 2.0.
return
cursor
.
query
if
cursor
.
query
is
not
None
:
return
cursor
.
query
.
decode
(
'utf-8'
)
return
None
def
return_insert_id
(
self
):
return
"RETURNING
%
s"
,
()
...
...
tests/regressiontests/backends/tests.py
Dosyayı görüntüle @
e9ef9776
...
...
@@ -125,20 +125,14 @@ class DateQuotingTest(TestCase):
classes
=
models
.
SchoolClass
.
objects
.
filter
(
last_updated__day
=
20
)
self
.
assertEqual
(
len
(
classes
),
1
)
class
LastExecutedQueryTest
(
TestCase
):
def
setUp
(
self
):
# connection.queries will not be filled in without this
settings
.
DEBUG
=
True
def
tearDown
(
self
):
settings
.
DEBUG
=
False
# There are no tests for the sqlite backend because it does not
class
LastExecutedQueryTest
(
TestCase
):
# There are no escaping tests for the sqlite backend because it does not
# implement paramater escaping. See #14091.
@unittest.skipUnless
(
connection
.
vendor
in
(
'oracle'
,
'postgresql'
),
"These backends use the standard parameter escaping rules"
)
@override_settings
(
DEBUG
=
True
)
def
test_parameter_escaping
(
self
):
# check that both numbers and string are properly quoted
list
(
models
.
Tag
.
objects
.
filter
(
name
=
"special:
\\\"
':"
,
object_id
=
12
))
...
...
@@ -148,6 +142,7 @@ class LastExecutedQueryTest(TestCase):
@unittest.skipUnless
(
connection
.
vendor
==
'mysql'
,
"MySQL uses backslashes to escape parameters."
)
@override_settings
(
DEBUG
=
True
)
def
test_parameter_escaping
(
self
):
list
(
models
.
Tag
.
objects
.
filter
(
name
=
"special:
\\\"
':"
,
object_id
=
12
))
sql
=
connection
.
queries
[
-
1
][
'sql'
]
...
...
@@ -155,6 +150,17 @@ class LastExecutedQueryTest(TestCase):
self
.
assertTrue
(
"= 'special:
\\\\\\\"\\
':' "
in
sql
)
self
.
assertTrue
(
"= 12 "
in
sql
)
def
test_query_encoding
(
self
):
"""
Test that last_executed_query() returns an Unicode string
"""
tags
=
models
.
Tag
.
objects
.
filter
(
name
=
"й"
,
object_id
=
12
)
.
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
,
unicode
))
class
ParameterHandlingTest
(
TestCase
):
def
test_bad_parameter_count
(
self
):
"An executemany call with too many/not enough parameters will raise an exception (Refs #12612)"
...
...
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