Django

Code

Ticket #2358: mssql.diff

File mssql.diff, 3.1 kB (added by Dan Hristodorescu, 2 years ago)
  • django/db/backends/ado_mssql/base.py

    old new  
    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

    old new  
    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

    old new  
    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

    old new  
    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)