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
b7fdd60d
Kaydet (Commit)
b7fdd60d
authored
Ara 15, 2015
tarafından
Stewart Park
Kaydeden (comit)
Tim Graham
Ara 15, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24675 -- Skipped SQL_AUTO_IS_NULL query on MySQL if not needed.
üst
3d223677
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
base.py
django/db/backends/mysql/base.py
+7
-6
features.py
django/db/backends/mysql/features.py
+6
-0
test_mysql.py
tests/backends/test_mysql.py
+20
-0
No files found.
django/db/backends/mysql/base.py
Dosyayı görüntüle @
b7fdd60d
...
...
@@ -267,12 +267,13 @@ class DatabaseWrapper(BaseDatabaseWrapper):
return
conn
def
init_connection_state
(
self
):
with
self
.
cursor
()
as
cursor
:
# SQL_AUTO_IS_NULL in MySQL controls whether an AUTO_INCREMENT column
# on a recently-inserted row will return when the field is tested for
# NULL. Disabling this value brings this aspect of MySQL in line with
# SQL standards.
cursor
.
execute
(
'SET SQL_AUTO_IS_NULL = 0'
)
if
self
.
features
.
is_sql_auto_is_null_enabled
:
with
self
.
cursor
()
as
cursor
:
# SQL_AUTO_IS_NULL controls whether an AUTO_INCREMENT column on
# a recently inserted row will return when the field is tested
# for NULL. Disabling this brings this aspect of MySQL in line
# with SQL standards.
cursor
.
execute
(
'SET SQL_AUTO_IS_NULL = 0'
)
def
create_cursor
(
self
):
cursor
=
self
.
connection
.
cursor
()
...
...
django/db/backends/mysql/features.py
Dosyayı görüntüle @
b7fdd60d
...
...
@@ -69,3 +69,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
def
introspected_boolean_field_type
(
self
,
*
args
,
**
kwargs
):
return
'IntegerField'
@cached_property
def
is_sql_auto_is_null_enabled
(
self
):
with
self
.
connection
.
cursor
()
as
cursor
:
cursor
.
execute
(
'SELECT @@SQL_AUTO_IS_NULL'
)
return
cursor
.
fetchone
()[
0
]
==
1
tests/backends/test_mysql.py
0 → 100644
Dosyayı görüntüle @
b7fdd60d
from
__future__
import
unicode_literals
import
unittest
from
django.db
import
connection
from
django.test
import
TestCase
,
override_settings
@override_settings
(
DEBUG
=
True
)
@unittest.skipUnless
(
connection
.
vendor
==
'mysql'
,
'MySQL specific test.'
)
class
MySQLTests
(
TestCase
):
def
test_auto_is_null_auto_config
(
self
):
query
=
'set sql_auto_is_null = 0'
connection
.
init_connection_state
()
last_query
=
connection
.
queries
[
-
1
][
'sql'
]
.
lower
()
if
connection
.
features
.
is_sql_auto_is_null_enabled
:
self
.
assertIn
(
query
,
last_query
)
else
:
self
.
assertNotIn
(
query
,
last_query
)
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