Ticket #18176: sql_query_fix.diff

File sql_query_fix.diff, 2.1 KB (added by rrotaru, 13 years ago)
  • django/db/backends/mysql/base.py

    diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
    index ecbb02f..3fe89af 100644
    a b class DatabaseOperations(BaseDatabaseOperations):  
    310310
    311311    def year_lookup_bounds(self, value):
    312312        # Again, no microseconds
    313         first = '%s-01-01 00:00:00'
    314         second = '%s-12-31 23:59:59.99'
    315         return [first % value, second % value]
     313        first = datetime.datetime(value,1,1,0,0,0)
     314        second = datetime.datetime(value,12,31,23,59,59,99)
     315        return [first, second]
    316316
    317317    def max_name_length(self):
    318318        return 64
  • django/db/backends/oracle/base.py

    diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
    index 9c91baa..7797ebb 100644
    a b WHEN (new.%(col_name)s IS NULL)  
    363363                                 value.second, value.microsecond)
    364364
    365365    def year_lookup_bounds_for_date_field(self, value):
    366         first = '%s-01-01'
    367         second = '%s-12-31'
    368         return [first % value, second % value]
     366        first = datetime.datetime(value,1,1)
     367        second = datetime.datetime(value,12,31)
     368        return [first, second]
    369369
    370370    def combine_expression(self, connector, sub_expressions):
    371371        "Oracle requires special cases for %% and & operators in query expressions"
  • django/db/backends/sqlite3/base.py

    diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
    index 7ce9dd3..718d10e 100644
    a b class DatabaseOperations(BaseDatabaseOperations):  
    179179        return unicode(value)
    180180
    181181    def year_lookup_bounds(self, value):
    182         first = '%s-01-01'
    183         second = '%s-12-31 23:59:59.999999'
    184         return [first % value, second % value]
     182        first = datetime.datetime(value,1,1)
     183        second = datetime.datetime(value,12,31,23,59,59,999999)
     184        return [first, second]
    185185
    186186    def convert_values(self, value, field):
    187187        """SQLite returns floats when it should be returning decimals,
Back to Top