summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/operations.py
diff options
context:
space:
mode:
authorAnatol Ulrich <anatol@versteht.es>2019-10-01 00:12:19 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-02 10:41:34 +0200
commit8ed6788aa479034a44a8aa87da47de56dd728c95 (patch)
tree1beb121695f5b6331bc8bc2d7fb2f7e808034026 /django/db/backends/mysql/operations.py
parente1aa93280276c7197637a763344cb9740d0e91ff (diff)
downloaddjango-8ed6788aa479034a44a8aa87da47de56dd728c95.tar.gz
Fixed #30821 -- Added ExtractIsoWeekYear database function and iso_week_day lookup.
Diffstat (limited to 'django/db/backends/mysql/operations.py')
-rw-r--r--django/db/backends/mysql/operations.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index e940286720..49ee2919f2 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -36,8 +36,10 @@ class DatabaseOperations(BaseDatabaseOperations):
# https://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
if lookup_type == 'week_day':
# DAYOFWEEK() returns an integer, 1-7, Sunday=1.
- # Note: WEEKDAY() returns 0-6, Monday=0.
return "DAYOFWEEK(%s)" % field_name
+ elif lookup_type == 'iso_week_day':
+ # WEEKDAY() returns an integer, 0-6, Monday=0.
+ return "WEEKDAY(%s) + 1" % field_name
elif lookup_type == 'week':
# Override the value of default_week_format for consistency with
# other database backends.