Commits

Michael Manfre  committed 46109a8

Remap 'week_day' lookup_type to SQL server recognized 'weekday'

  • Participants
  • Parent commits 0b19f3b

Comments (0)

Files changed (2)

File docs/changelog.txt

 
 - Updated SQLInsertCompiler to work with Django 1.4
 - Added support for ``disable_constraint_checking``, which is required for ``loaddata`` to work properly.
-- Implemented ``DatabaseOperations.date_interval_sql`` to allow using expressions like ``end__lte=F('start')+delta``.
+- Implemented ``DatabaseOperations.date_interval_sql`` to allow using expressions like ``end__lte=F('start')+delta``.
+- Fixed date part extraction for ``week_day``.

File sqlserver_ado/operations.py

     compiler_module = "sqlserver_ado.compiler"
     
     def date_extract_sql(self, lookup_type, field_name):
-        return "DATEPART(%s, %s)" % (lookup_type, self.quote_name(field_name))
+        if lookup_type == 'week_day':
+            lookup_type = 'weekday'
+        return 'DATEPART({0}, {1})'.format(
+            lookup_type,
+            self.quote_name(field_name),
+        )
 
     def date_interval_sql(self, sql, connector, timedelta):
         """