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
f2e2a1bd
Unverified
Kaydet (Commit)
f2e2a1bd
authored
Eki 15, 2018
tarafından
Mariusz Felisiak
Kaydeden (comit)
GitHub
Eki 15, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29845 -- Fixed Cast crash on MySQL when casting to DecimalField.
üst
f07091a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
operations.py
django/db/backends/mysql/operations.py
+1
-0
test_cast.py
tests/db_functions/comparison/test_cast.py
+15
-1
No files found.
django/db/backends/mysql/operations.py
Dosyayı görüntüle @
f2e2a1bd
...
...
@@ -19,6 +19,7 @@ class DatabaseOperations(BaseDatabaseOperations):
'AutoField'
:
'signed integer'
,
'BigAutoField'
:
'signed integer'
,
'CharField'
:
'char(
%(max_length)
s)'
,
'DecimalField'
:
'decimal(
%(max_digits)
s,
%(decimal_places)
s)'
,
'TextField'
:
'char'
,
'IntegerField'
:
'signed integer'
,
'BigIntegerField'
:
'signed integer'
,
...
...
tests/db_functions/comparison/test_cast.py
Dosyayı görüntüle @
f2e2a1bd
...
...
@@ -10,7 +10,7 @@ from django.test import (
TestCase
,
ignore_warnings
,
override_settings
,
skipUnlessDBFeature
,
)
from
..models
import
Author
,
DTModel
,
Fan
from
..models
import
Author
,
DTModel
,
Fan
,
FloatModel
class
CastTests
(
TestCase
):
...
...
@@ -37,6 +37,20 @@ class CastTests(TestCase):
names
=
Author
.
objects
.
annotate
(
cast_string
=
Cast
(
'name'
,
models
.
CharField
(
max_length
=
1
)))
self
.
assertEqual
(
names
.
get
()
.
cast_string
,
'B'
)
@skipUnlessDBFeature
(
'supports_cast_with_precision'
)
def
test_cast_to_decimal_field
(
self
):
FloatModel
.
objects
.
create
(
f1
=-
1.934
,
f2
=
3.467
)
float_obj
=
FloatModel
.
objects
.
annotate
(
cast_f1_decimal
=
Cast
(
'f1'
,
models
.
DecimalField
(
max_digits
=
8
,
decimal_places
=
2
)),
cast_f2_decimal
=
Cast
(
'f2'
,
models
.
DecimalField
(
max_digits
=
8
,
decimal_places
=
1
)),
)
.
get
()
self
.
assertEqual
(
float_obj
.
cast_f1_decimal
,
decimal
.
Decimal
(
'-1.93'
))
self
.
assertEqual
(
float_obj
.
cast_f2_decimal
,
decimal
.
Decimal
(
'3.5'
))
author_obj
=
Author
.
objects
.
annotate
(
cast_alias_decimal
=
Cast
(
'alias'
,
models
.
DecimalField
(
max_digits
=
8
,
decimal_places
=
2
)),
)
.
get
()
self
.
assertEqual
(
author_obj
.
cast_alias_decimal
,
decimal
.
Decimal
(
'1'
))
def
test_cast_to_integer
(
self
):
for
field_class
in
(
models
.
AutoField
,
...
...
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