Ticket #2358: mssql_update1.diff

File mssql_update1.diff, 4.4 KB (added by Dan Hristodorescu, 18 years ago)

forgot brackets and added microseconds check

  • django/contrib/sessions/middleware.py

     
    5252                self._session_cache = {}
    5353            else:
    5454                try:
     55                    datenow = datetime.datetime.now()
     56                    if hasattr(datenow, 'microsecond'):
     57                        datenow = datenow.replace(microsecond=0)
    5558                    s = Session.objects.get(session_key=self.session_key,
    56                         expire_date__gt=datetime.datetime.now())
     59                        expire_date__gt=datenow)
    5760                    self._session_cache = s.get_decoded()
    5861                except Session.DoesNotExist:
    5962                    self._session_cache = {}
  • django/db/backends/ado_mssql/base.py

     
    7070            # TODO: Handle DATABASE_PORT.
    7171            conn_string = "PROVIDER=SQLOLEDB;DATA SOURCE=%s;UID=%s;PWD=%s;DATABASE=%s" % (settings.DATABASE_HOST, settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME)
    7272            self.connection = Database.connect(conn_string)
    73         cursor = self.connection.cursor()
     73        cursor = Cursor(self.connection)
    7474        if settings.DEBUG:
    7575            return util.CursorDebugWrapper(cursor, self)
    7676        return cursor
     
    117117
    118118def get_limit_offset_sql(limit, offset=None):
    119119    # TODO: This is a guess. Make sure this is correct.
    120     sql = "LIMIT %s" % limit
    121     if offset and offset != 0:
    122         sql += " OFFSET %s" % offset
    123     return sql
     120    # should be "SELECT TOP %s" % limit
     121    # not LIMIT at the end
     122    return ""
     123    #sql = "LIMIT %s" % limit
     124    #if offset and offset != 0:
     125    #    sql += " OFFSET %s" % offset
     126    #return sql
    124127
    125128def get_random_function_sql():
    126129    return "RAND()"
  • django/db/backends/ado_mssql/introspection.py

     
    11def get_table_list(cursor):
    2     raise NotImplementedError
     2    cursor.execute('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES')
     3    return [row[0] for row in cursor.fetchall()]
    34
    45def get_table_description(cursor, table_name):
    56    raise NotImplementedError
  • django/db/models/base.py

     
    172172        record_exists = True
    173173        if pk_set:
    174174            # Determine whether a record with the primary key already exists.
    175             cursor.execute("SELECT 1 FROM %s WHERE %s=%%s LIMIT 1" % \
     175            cursor.execute("SELECT 1 FROM %s WHERE %s=%%s" % \
    176176                (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), [pk_val])
    177177            # If it does already exist, do an UPDATE.
    178178            if cursor.fetchone():
  • django/db/models/fields/__init__.py

     
    478478        if value is not None:
    479479            # MySQL will throw a warning if microseconds are given, because it
    480480            # doesn't support microseconds.
    481             if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
     481            if (settings.DATABASE_ENGINE == 'mysql' or settings.DATABASE_ENGINE == 'ado_mssql') and hasattr(value, 'microsecond'):
    482482                value = value.replace(microsecond=0)
    483483            value = str(value)
    484484        return Field.get_db_prep_save(self, value)
     
    742742        if value is not None:
    743743            # MySQL will throw a warning if microseconds are given, because it
    744744            # doesn't support microseconds.
    745             if settings.DATABASE_ENGINE == 'mysql':
     745            if settings.DATABASE_ENGINE == 'mysql' or settings.DATABASE_ENGINE == 'ado_mssql':
    746746                value = value.replace(microsecond=0)
    747747            value = str(value)
    748748        return Field.get_db_prep_save(self, value)
Back to Top