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
e707e4c7
Kaydet (Commit)
e707e4c7
authored
Ara 30, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #19738 -- Removed timezone conversion in SQL queries executed outside of the ORM.
Per deprecation timeline.
üst
b2ffbb00
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
49 deletions
+8
-49
base.py
django/db/backends/mysql/base.py
+2
-21
base.py
django/db/backends/oracle/base.py
+1
-10
base.py
django/db/backends/sqlite3/base.py
+0
-18
2.0.txt
docs/releases/2.0.txt
+5
-0
No files found.
django/db/backends/mysql/base.py
Dosyayı görüntüle @
e707e4c7
...
...
@@ -6,18 +6,14 @@ MySQLdb is supported for Python 2 only: http://sourceforge.net/projects/mysql-py
"""
from
__future__
import
unicode_literals
import
datetime
import
re
import
sys
import
warnings
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
utils
from
django.db.backends
import
utils
as
backend_utils
from
django.db.backends.base.base
import
BaseDatabaseWrapper
from
django.utils
import
six
,
timezone
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils
import
six
from
django.utils.encoding
import
force_str
from
django.utils.functional
import
cached_property
from
django.utils.safestring
import
SafeBytes
,
SafeText
...
...
@@ -31,7 +27,7 @@ except ImportError as e:
)
from
MySQLdb.constants
import
CLIENT
,
FIELD_TYPE
# isort:skip
from
MySQLdb.converters
import
Thing2Literal
,
conversions
# isort:skip
from
MySQLdb.converters
import
conversions
# isort:skip
# Some of these import MySQLdb, so import them after checking if it's installed.
from
.client
import
DatabaseClient
# isort:skip
...
...
@@ -51,20 +47,6 @@ if (version < (1, 2, 1) or (
raise
ImproperlyConfigured
(
"MySQLdb-1.2.1p2 or newer is required; you have
%
s"
%
Database
.
__version__
)
def
adapt_datetime_warn_on_aware_datetime
(
value
,
conv
):
# Remove this function and rely on the default adapter in Django 2.0.
if
settings
.
USE_TZ
and
timezone
.
is_aware
(
value
):
warnings
.
warn
(
"The MySQL database adapter received an aware datetime (
%
s), "
"probably from cursor.execute(). Update your code to pass a "
"naive datetime in the database connection's time zone (UTC by "
"default)."
,
RemovedInDjango20Warning
)
# This doesn't account for the database connection's timezone,
# which isn't known. (That's why this adapter is deprecated.)
value
=
value
.
astimezone
(
timezone
.
utc
)
.
replace
(
tzinfo
=
None
)
return
Thing2Literal
(
value
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S.
%
f"
),
conv
)
# MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like
# timedelta in terms of actual behavior as they are signed and include days --
# and Django expects time, so we still need to override that. We also need to
...
...
@@ -75,7 +57,6 @@ django_conversions.update({
FIELD_TYPE
.
TIME
:
backend_utils
.
typecast_time
,
FIELD_TYPE
.
DECIMAL
:
backend_utils
.
typecast_decimal
,
FIELD_TYPE
.
NEWDECIMAL
:
backend_utils
.
typecast_decimal
,
datetime
.
datetime
:
adapt_datetime_warn_on_aware_datetime
,
})
# This should match the numerical portion of the version numbers (we can treat
...
...
django/db/backends/oracle/base.py
Dosyayı görüntüle @
e707e4c7
...
...
@@ -10,14 +10,12 @@ import decimal
import
os
import
platform
import
sys
import
warnings
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
utils
from
django.db.backends.base.base
import
BaseDatabaseWrapper
from
django.utils
import
six
,
timezone
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils
import
six
from
django.utils.encoding
import
force_bytes
,
force_text
from
django.utils.functional
import
cached_property
...
...
@@ -326,13 +324,6 @@ class OracleParam(object):
# without being converted by DateTimeField.get_db_prep_value.
if
settings
.
USE_TZ
and
(
isinstance
(
param
,
datetime
.
datetime
)
and
not
isinstance
(
param
,
Oracle_datetime
)):
if
timezone
.
is_aware
(
param
):
warnings
.
warn
(
"The Oracle database adapter received an aware datetime (
%
s), "
"probably from cursor.execute(). Update your code to pass a "
"naive datetime in the database connection's time zone (UTC by "
"default)."
,
RemovedInDjango20Warning
)
param
=
param
.
astimezone
(
timezone
.
utc
)
.
replace
(
tzinfo
=
None
)
param
=
Oracle_datetime
.
from_datetime
(
param
)
string_size
=
0
...
...
django/db/backends/sqlite3/base.py
Dosyayı görüntüle @
e707e4c7
...
...
@@ -6,14 +6,12 @@ standard library.
"""
from
__future__
import
unicode_literals
import
datetime
import
decimal
import
re
import
warnings
import
pytz
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
utils
from
django.db.backends
import
utils
as
backend_utils
...
...
@@ -22,7 +20,6 @@ from django.utils import six, timezone
from
django.utils.dateparse
import
(
parse_date
,
parse_datetime
,
parse_duration
,
parse_time
,
)
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils.encoding
import
force_text
from
django.utils.safestring
import
SafeBytes
...
...
@@ -43,20 +40,6 @@ from .operations import DatabaseOperations # isort:skip
from
.schema
import
DatabaseSchemaEditor
# isort:skip
def
adapt_datetime_warn_on_aware_datetime
(
value
):
# Remove this function and rely on the default adapter in Django 2.0.
if
settings
.
USE_TZ
and
timezone
.
is_aware
(
value
):
warnings
.
warn
(
"The SQLite database adapter received an aware datetime (
%
s), "
"probably from cursor.execute(). Update your code to pass a "
"naive datetime in the database connection's time zone (UTC by "
"default)."
,
RemovedInDjango20Warning
)
# This doesn't account for the database connection's timezone,
# which isn't known. (That's why this adapter is deprecated.)
value
=
value
.
astimezone
(
timezone
.
utc
)
.
replace
(
tzinfo
=
None
)
return
value
.
isoformat
(
str
(
" "
))
def
decoder
(
conv_func
):
""" The Python sqlite3 interface returns always byte strings.
This function converts the received value to a regular string before
...
...
@@ -73,7 +56,6 @@ Database.register_converter(str("timestamp"), decoder(parse_datetime))
Database
.
register_converter
(
str
(
"TIMESTAMP"
),
decoder
(
parse_datetime
))
Database
.
register_converter
(
str
(
"decimal"
),
decoder
(
backend_utils
.
typecast_decimal
))
Database
.
register_adapter
(
datetime
.
datetime
,
adapt_datetime_warn_on_aware_datetime
)
Database
.
register_adapter
(
decimal
.
Decimal
,
backend_utils
.
rev_typecast_decimal
)
if
six
.
PY2
:
Database
.
register_adapter
(
str
,
lambda
s
:
s
.
decode
(
'utf-8'
))
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
e707e4c7
...
...
@@ -254,3 +254,8 @@ these features.
required.
* ``django.db.models.fields.add_lazy_relation()`` is removed.
* When time zone support is enabled, database backends that don't support time
zones no longer convert aware datetimes to naive values in UTC anymore when
such values are passed as parameters to SQL queries executed outside of the
ORM, e.g. with ``cursor.execute()``.
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