Commits

Anonymous committed c60811f

Added null float model.

Comments (0)

Files changed (6)

src/sqlserver_ado/adodb_django.py

         - Parameters are generated incorrectly for use in UDFs.
     * DateObjectFromCOMDate always returns a DateTime, as this is what Django template
     	filters expect from a DateTimeField
-	* Inlined Django monkeypatching of ConvertVariantToPython
+	* In-lined Django monkeypatching of ConvertVariantToPython
 	
 	Python's DB-API 2.0:
 	http://www.python.org/dev/peps/pep-0249/
 	desc = list()
 	for param in parameters:
 		desc.append("Name: %s, Type: %s, Size: %s" % \
-			(param.Name, adTypeNames.get(param.Type, str(param.Type)+'(unknown type)'), param.Size))
+			(param.Name, adTypeNames.get(param.Type, str(param.Type)+' (unknown type)'), param.Size))
 		
 	return '[' + ', '.join(desc) + ']'
 
 class Connection(object):
-    def __init__(self,adoConn):
+    def __init__(self, adoConn):
         self.adoConn = adoConn
         self.errorhandler = None
         self.messages = []
                 self.supportsTransactions = (prop.Value > 0)
                 return
 
-    def _raiseConnectionError(self,errorclass,errorvalue):
+    def _raiseConnectionError(self, errorclass, errorvalue):
         eh = self.errorhandler
         if eh is None:
             eh = standardErrorHandler
-        eh(self,None,errorclass,errorvalue)
+        eh(self, None, errorclass, errorvalue)
 
     def _closeAdoConnection(self):
         """close the underlying ADO Connection object,
                     #If not, we will have to start a new transaction by this command:
                     self.adoConn.BeginTrans()
         except (Exception), e:
-            self._raiseConnectionError(Error,e)
+            self._raiseConnectionError(Error, e)
 
     def rollback(self):
         """In case a database does provide transactions this method causes the the database to roll back to
                 #If not, we will have to start a new transaction by this command:
                 self.adoConn.BeginTrans()
         else:
-            self._raiseConnectionError(NotSupportedError,None)
+            self._raiseConnectionError(NotSupportedError, None)
 
         #TODO: Could implement the prefered method by having two classes,
         # one with trans and one without, and make the connect function choose which one.
     def __iter__(self):
         return iter(self.fetchone, None)
 
-    def _raiseCursorError(self,errorclass,errorvalue):
+    def _raiseCursorError(self, errorclass, errorvalue):
         eh = self.errorhandler
         if eh is None:
             eh = standardErrorHandler
             then available through the standard fetchXXX() methods.
         """
         self.messages = []
-        return self._executeHelper(procname,True,parameters)
+        return self._executeHelper(procname, True, parameters)
 
-    def _returnADOCommandParameters(self,adoCommand):
+    def _returnADOCommandParameters(self, adoCommand):
         retLst = []
         for p in adoCommand.Parameters:
             if verbose > 2:
                 retLst.append(pyObject)
         return retLst
 
-    def _makeDescriptionFromRS(self,rs):
+    def _makeDescriptionFromRS(self, recordset):
     	# Abort if closed or no recordset.
-        if (rs is None) or (rs.State == adStateClosed):
-            self.rs = None
+        if (recordset is None) or (recordset.State == adStateClosed):
+            self.recordset = None
             self.description = None
             return
 
         # Switching to client-side cursors will force a static cursor,
         # and rowcount will then be set accurately [Cole]
         self.rowcount = -1
-        self.rs = rs
+        self.rs = recordset
         self.description = []
         
         for i in range(self.rs.Fields.Count):
-            f = rs.Fields(i)
+            f = self.rs.Fields(i)
             
             display_size = None            
             if not(self.rs.EOF or self.rs.BOF):
         if self.rs and self.rs.State != adStateClosed:
             self.rs.Close()
             self.rs = None
-
+            
     def _executeHelper(self, operation, isStoredProcedureCall, parameters=None):
         if self.conn is None:
             self._raiseCursorError(Error,None)

tests/create_database.sql

-IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'django_test_backend')
-DROP DATABASE [django_test_backend]
-go
-
-create database [django_test_backend]
-go
-
-use [django_test_backend]
-GO
-
-create table [table has spaces] (
-	[Create User] [nvarchar](30) NULL DEFAULT (''),
-	[Create Timestamp] [datetime] NOT NULL DEFAULT (getdate())
-)
-go
-
-use [master]
-go

tests/test_bug_009/dump_all.py

 from myapp.models import *
 
-for klass in (TableNullText, TableNullInteger, TableNullDateTime, TableNullDate, TableNullTime, TableNullBoolean, TableNullDecimal):
+for klass in all_tables:
 	print list(klass.objects.all())

tests/test_bug_009/insert_null.py

 from myapp.models import *
 
-for klass in (TableNullText, TableNullInteger, TableNullDateTime, TableNullDate, TableNullTime, TableNullBoolean, TableNullDecimal):
+for klass in all_tables:
 	obj = klass(amount=None)
 	obj.save()

tests/test_bug_009/myapp/models.py

 from django.db import models
 
-class TableNullText(models.Model):
-	amount = models.TextField(null=True)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
-		
-class TableNullInteger(models.Model):
-	amount = models.IntegerField(null=True)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
+class BaseModel(models.Model):
+    def __unicode__(self):
+        return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
 
-class TableNullDateTime(models.Model):
-	amount = models.DateTimeField(null=True)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
-		
-class TableNullDate(models.Model):
-	amount = models.DateField(null=True)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
-		
-class TableNullTime(models.Model):
-	amount = models.TimeField(null=True)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
-		
-class TableNullBoolean(models.Model):
-	amount = models.BooleanField(null=True)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
+    class Meta:
+        abstract = True
 
-class TableNullDecimal(models.Model):
-	amount = models.DecimalField(null=True, max_digits=4, decimal_places=2)
-	
-	def __unicode__(self):
-		return u'id: ' + unicode(self.id) + ' Amount: ' + unicode(self.amount)
+
+class TableNullText(BaseModel):
+    amount = models.TextField(null=True)
+
+class TableNullInteger(BaseModel):
+    amount = models.IntegerField(null=True)
+
+class TableNullDateTime(BaseModel):
+    amount = models.DateTimeField(null=True)
+
+class TableNullDate(BaseModel):
+    amount = models.DateField(null=True)
+
+class TableNullTime(BaseModel):
+    amount = models.TimeField(null=True)
+
+class TableNullBoolean(BaseModel):
+    amount = models.BooleanField(null=True)
+
+class TableNullNullBoolean(BaseModel):
+    amount = models.NullBooleanField(null=True)
+
+class TableNullDecimal(BaseModel):
+    amount = models.DecimalField(null=True, max_digits=4, decimal_places=2)
+
+class TableNullFloat(BaseModel):
+    amount = models.FloatField(null=True)
+
+all_tables = (TableNullText, TableNullInteger, TableNullDateTime, TableNullDate, TableNullTime, TableNullBoolean, TableNullNullBoolean, TableNullDecimal, TableNullFloat)

tests/test_inspectdb/create_database.sql

+IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'django_test_backend')
+DROP DATABASE [django_test_backend]
+go
+
+create database [django_test_backend]
+go
+
+use [django_test_backend]
+GO
+
+create table [table has spaces] (
+	[Create User] [nvarchar](30) NULL DEFAULT (''),
+	[Create Timestamp] [datetime] NOT NULL DEFAULT (getdate())
+)
+go
+
+use [master]
+go
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.