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
45c035c8
Kaydet (Commit)
45c035c8
authored
Tem 09, 2018
tarafından
Tom Forbes
Kaydeden (comit)
Tim Graham
Tem 09, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #29548 -- Fixed non-GIS test failures on MariaDB.
üst
7d6fe18d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
features.py
django/db/backends/mysql/features.py
+5
-3
operations.py
django/db/backends/mysql/operations.py
+13
-0
test_features.py
tests/backends/mysql/test_features.py
+2
-0
No files found.
django/db/backends/mysql/features.py
Dosyayı görüntüle @
45c035c8
...
@@ -80,18 +80,20 @@ class DatabaseFeatures(BaseDatabaseFeatures):
...
@@ -80,18 +80,20 @@ class DatabaseFeatures(BaseDatabaseFeatures):
@cached_property
@cached_property
def
supports_over_clause
(
self
):
def
supports_over_clause
(
self
):
if
self
.
connection
.
mysql_is_mariadb
:
return
self
.
connection
.
mysql_version
>=
(
10
,
2
)
return
self
.
connection
.
mysql_version
>=
(
8
,
0
,
2
)
return
self
.
connection
.
mysql_version
>=
(
8
,
0
,
2
)
@cached_property
@cached_property
def
has_select_for_update_skip_locked
(
self
):
def
has_select_for_update_skip_locked
(
self
):
return
self
.
connection
.
mysql_version
>=
(
8
,
0
,
1
)
return
not
self
.
connection
.
mysql_is_mariadb
and
self
.
connection
.
mysql_version
>=
(
8
,
0
,
1
)
has_select_for_update_nowait
=
has_select_for_update_skip_locked
has_select_for_update_nowait
=
has_select_for_update_skip_locked
@cached_property
@cached_property
def
needs_explain_extended
(
self
):
def
needs_explain_extended
(
self
):
# EXTENDED is deprecated (and not required) in
5.7 and removed in 8.0
.
# EXTENDED is deprecated (and not required) in
MySQL 5.7
.
return
self
.
connection
.
mysql_version
<
(
5
,
7
)
return
not
self
.
connection
.
mysql_is_mariadb
and
self
.
connection
.
mysql_version
<
(
5
,
7
)
@cached_property
@cached_property
def
supports_transactions
(
self
):
def
supports_transactions
(
self
):
...
...
django/db/backends/mysql/operations.py
Dosyayı görüntüle @
45c035c8
import
decimal
import
uuid
import
uuid
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -260,10 +261,22 @@ class DatabaseOperations(BaseDatabaseOperations):
...
@@ -260,10 +261,22 @@ class DatabaseOperations(BaseDatabaseOperations):
def
binary_placeholder_sql
(
self
,
value
):
def
binary_placeholder_sql
(
self
,
value
):
return
'_binary
%
s'
if
value
is
not
None
and
not
hasattr
(
value
,
'as_sql'
)
else
'
%
s'
return
'_binary
%
s'
if
value
is
not
None
and
not
hasattr
(
value
,
'as_sql'
)
else
'
%
s'
def
convert_durationfield_value
(
self
,
value
,
expression
,
connection
):
# DurationFields can return a Decimal in MariaDB.
if
isinstance
(
value
,
decimal
.
Decimal
):
value
=
float
(
value
)
return
super
()
.
convert_durationfield_value
(
value
,
expression
,
connection
)
def
subtract_temporals
(
self
,
internal_type
,
lhs
,
rhs
):
def
subtract_temporals
(
self
,
internal_type
,
lhs
,
rhs
):
lhs_sql
,
lhs_params
=
lhs
lhs_sql
,
lhs_params
=
lhs
rhs_sql
,
rhs_params
=
rhs
rhs_sql
,
rhs_params
=
rhs
if
internal_type
==
'TimeField'
:
if
internal_type
==
'TimeField'
:
if
self
.
connection
.
mysql_is_mariadb
:
# MariaDB includes the microsecond component in TIME_TO_SEC as
# a decimal. MySQL returns an integer without microseconds.
return
'((TIME_TO_SEC(
%(lhs)
s) - TIME_TO_SEC(
%(rhs)
s)) * 1000000)'
%
{
'lhs'
:
lhs_sql
,
'rhs'
:
rhs_sql
},
lhs_params
+
rhs_params
return
(
return
(
"((TIME_TO_SEC(
%(lhs)
s) * 1000000 + MICROSECOND(
%(lhs)
s)) -"
"((TIME_TO_SEC(
%(lhs)
s) * 1000000 + MICROSECOND(
%(lhs)
s)) -"
" (TIME_TO_SEC(
%(rhs)
s) * 1000000 + MICROSECOND(
%(rhs)
s)))"
" (TIME_TO_SEC(
%(rhs)
s) * 1000000 + MICROSECOND(
%(rhs)
s)))"
...
...
tests/backends/mysql/test_features.py
Dosyayı görüntüle @
45c035c8
...
@@ -22,11 +22,13 @@ class TestFeatures(TestCase):
...
@@ -22,11 +22,13 @@ class TestFeatures(TestCase):
def
test_skip_locked_no_wait
(
self
):
def
test_skip_locked_no_wait
(
self
):
with
mock
.
MagicMock
()
as
_connection
:
with
mock
.
MagicMock
()
as
_connection
:
_connection
.
mysql_version
=
(
8
,
0
,
1
)
_connection
.
mysql_version
=
(
8
,
0
,
1
)
_connection
.
mysql_is_mariadb
=
False
database_features
=
DatabaseFeatures
(
_connection
)
database_features
=
DatabaseFeatures
(
_connection
)
self
.
assertTrue
(
database_features
.
has_select_for_update_skip_locked
)
self
.
assertTrue
(
database_features
.
has_select_for_update_skip_locked
)
self
.
assertTrue
(
database_features
.
has_select_for_update_nowait
)
self
.
assertTrue
(
database_features
.
has_select_for_update_nowait
)
with
mock
.
MagicMock
()
as
_connection
:
with
mock
.
MagicMock
()
as
_connection
:
_connection
.
mysql_version
=
(
8
,
0
,
0
)
_connection
.
mysql_version
=
(
8
,
0
,
0
)
_connection
.
mysql_is_mariadb
=
False
database_features
=
DatabaseFeatures
(
_connection
)
database_features
=
DatabaseFeatures
(
_connection
)
self
.
assertFalse
(
database_features
.
has_select_for_update_skip_locked
)
self
.
assertFalse
(
database_features
.
has_select_for_update_skip_locked
)
self
.
assertFalse
(
database_features
.
has_select_for_update_nowait
)
self
.
assertFalse
(
database_features
.
has_select_for_update_nowait
)
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