Author: ramiro
Date: 2012-02-29 09:46:23 -0800 (Wed, 29 Feb 2012)
New Revision: 17603

Removed:
   django/trunk/django/contrib/gis/db/backends/mysql/compiler.py
Modified:
   django/trunk/django/contrib/gis/db/backends/mysql/operations.py
   django/trunk/django/contrib/gis/db/models/sql/compiler.py
   django/trunk/django/contrib/gis/db/models/sql/query.py
   django/trunk/django/contrib/gis/tests/geoapp/models.py
   django/trunk/django/contrib/gis/tests/geoapp/test_regress.py
   django/trunk/django/db/backends/mysql/base.py
   django/trunk/django/db/backends/mysql/compiler.py
Log:
Fixed #17796 -- Rolled back [17588] because the fix for the original relatively
corner case (boolean fields under MySQL spatial backend) had a wider scope with
potentially unintended consequences affecting the main MySQL backend and the
required changes wouldn't be appropiate at this point of the 1.4 development
cycle.

Refs #15169.

Deleted: django/trunk/django/contrib/gis/db/backends/mysql/compiler.py
===================================================================
--- django/trunk/django/contrib/gis/db/backends/mysql/compiler.py       
2012-02-29 08:57:48 UTC (rev 17602)
+++ django/trunk/django/contrib/gis/db/backends/mysql/compiler.py       
2012-02-29 17:46:23 UTC (rev 17603)
@@ -1,22 +0,0 @@
-from django.contrib.gis.db.models.sql.compiler import GeoSQLCompiler as 
BaseGeoSQLCompiler
-from django.db.backends.mysql import compiler
-
-SQLCompiler = compiler.SQLCompiler
-
-class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
-    pass
-
-class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
-    pass
-
-class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
-    pass
-
-class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
-    pass
-
-class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
-    pass
-
-class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
-    pass

Modified: django/trunk/django/contrib/gis/db/backends/mysql/operations.py
===================================================================
--- django/trunk/django/contrib/gis/db/backends/mysql/operations.py     
2012-02-29 08:57:48 UTC (rev 17602)
+++ django/trunk/django/contrib/gis/db/backends/mysql/operations.py     
2012-02-29 17:46:23 UTC (rev 17603)
@@ -5,7 +5,7 @@
 
 class MySQLOperations(DatabaseOperations, BaseSpatialOperations):
 
-    compiler_module = 'django.contrib.gis.db.backends.mysql.compiler'
+    compiler_module = 'django.contrib.gis.db.models.sql.compiler'
     mysql = True
     name = 'mysql'
     select = 'AsText(%s)'

Modified: django/trunk/django/contrib/gis/db/models/sql/compiler.py
===================================================================
--- django/trunk/django/contrib/gis/db/models/sql/compiler.py   2012-02-29 
08:57:48 UTC (rev 17602)
+++ django/trunk/django/contrib/gis/db/models/sql/compiler.py   2012-02-29 
17:46:23 UTC (rev 17603)
@@ -185,10 +185,9 @@
                                self.query.extra_select_fields.get(a, None),
                                self.connection)
                   for v, a in izip(row[rn_offset:index_start], aliases)]
-
-        if self.connection.ops.oracle or self.connection.ops.mysql or 
getattr(self.query, 'geo_values', False):
-            # We resolve the rest of the columns if we're on MySQL, Oracle or
-            # if the `geo_values` attribute is defined.
+        if self.connection.ops.oracle or getattr(self.query, 'geo_values', 
False):
+            # We resolve the rest of the columns if we're on Oracle or if
+            # the `geo_values` attribute is defined.
             for value, field in map(None, row[index_start:], fields):
                 values.append(self.query.convert_values(value, field, 
self.connection))
         else:

Modified: django/trunk/django/contrib/gis/db/models/sql/query.py
===================================================================
--- django/trunk/django/contrib/gis/db/models/sql/query.py      2012-02-29 
08:57:48 UTC (rev 17602)
+++ django/trunk/django/contrib/gis/db/models/sql/query.py      2012-02-29 
17:46:23 UTC (rev 17603)
@@ -56,8 +56,8 @@
         extra selection objects into Geometry and Distance objects.
         TODO: Make converted objects 'lazy' for less overhead.
         """
-        if connection.ops.oracle or connection.ops.mysql:
-            # On MySQL and Oracle, call their version of `convert_values` 
first.
+        if connection.ops.oracle:
+            # Running through Oracle's first.
             value = super(GeoQuery, self).convert_values(value, field or 
GeomField(), connection)
 
         if value is None:

Modified: django/trunk/django/contrib/gis/tests/geoapp/models.py
===================================================================
--- django/trunk/django/contrib/gis/tests/geoapp/models.py      2012-02-29 
08:57:48 UTC (rev 17602)
+++ django/trunk/django/contrib/gis/tests/geoapp/models.py      2012-02-29 
17:46:23 UTC (rev 17603)
@@ -34,10 +34,6 @@
     objects = models.GeoManager()
     def __unicode__(self): return self.name
 
-class Truth(models.Model):
-    val = models.BooleanField()
-    objects = models.GeoManager()
-
 if not spatialite:
     class Feature(models.Model):
         name = models.CharField(max_length=20)

Modified: django/trunk/django/contrib/gis/tests/geoapp/test_regress.py
===================================================================
--- django/trunk/django/contrib/gis/tests/geoapp/test_regress.py        
2012-02-29 08:57:48 UTC (rev 17602)
+++ django/trunk/django/contrib/gis/tests/geoapp/test_regress.py        
2012-02-29 17:46:23 UTC (rev 17603)
@@ -7,7 +7,7 @@
 from django.db.models import Count
 from django.test import TestCase
 
-from .models import City, PennsylvaniaCity, State, Truth
+from .models import City, PennsylvaniaCity, State
 
 
 class GeoRegressionTests(TestCase):
@@ -64,11 +64,3 @@
         "Regression for #16409 - make sure defer() and only() work with 
annotate()"
         
self.assertIsInstance(list(City.objects.annotate(Count('point')).defer('name')),
 list)
         
self.assertIsInstance(list(City.objects.annotate(Count('point')).only('name')), 
list)
-
-    def test04_boolean_conversion(self):
-        "Testing Boolean value conversion with the spatial backend, see 
#15169."
-        t1 = Truth.objects.create(val=True)
-        t2 = Truth.objects.create(val=False)
-
-        self.assertTrue(Truth.objects.get(pk=1).val is True)
-        self.assertTrue(Truth.objects.get(pk=2).val is False)

Modified: django/trunk/django/db/backends/mysql/base.py
===================================================================
--- django/trunk/django/db/backends/mysql/base.py       2012-02-29 08:57:48 UTC 
(rev 17602)
+++ django/trunk/django/db/backends/mysql/base.py       2012-02-29 17:46:23 UTC 
(rev 17603)
@@ -190,12 +190,6 @@
 class DatabaseOperations(BaseDatabaseOperations):
     compiler_module = "django.db.backends.mysql.compiler"
 
-    def convert_values(self, value, field):
-        if (field and field.get_internal_type() in ("BooleanField", 
"NullBooleanField") and
-            value in (0, 1)):
-            value = bool(value)
-        return value
-
     def date_extract_sql(self, lookup_type, field_name):
         # http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
         if lookup_type == 'week_day':

Modified: django/trunk/django/db/backends/mysql/compiler.py
===================================================================
--- django/trunk/django/db/backends/mysql/compiler.py   2012-02-29 08:57:48 UTC 
(rev 17602)
+++ django/trunk/django/db/backends/mysql/compiler.py   2012-02-29 17:46:23 UTC 
(rev 17603)
@@ -5,7 +5,10 @@
         values = []
         index_extra_select = len(self.query.extra_select.keys())
         for value, field in map(None, row[index_extra_select:], fields):
-            values.append(self.query.convert_values(value, field, 
connection=self.connection))
+            if (field and field.get_internal_type() in ("BooleanField", 
"NullBooleanField") and
+                value in (0, 1)):
+                value = bool(value)
+            values.append(value)
         return row[:index_extra_select] + tuple(values)
 
 class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler):

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to