Commits

Anonymous committed c43c652

Added a sql like representation to the NonrelQuery to fix issues with the django cache machine extension

Comments (0)

Files changed (1)

djangotoolbox/db/basecompiler.py

         self.connection = compiler.connection
         self.query = self.compiler.query
         self._negated = False
+        self.filters = {}
 
     def fetch(self, low_mark=0, high_mark=None):
         raise NotImplementedError('Not implemented')
                 continue
 
             column, lookup_type, db_type, value = self._decode_child(child)
+            
+            self.filters[str(column)] = " " + lookup_type + " " + str(value)
             self.add_filter(column, lookup_type, self._negated, db_type, value)
 
         if filters.negated:
 
     def convert_value_for_db(self, db_type, value):
         return self.compiler.convert_value_for_db(db_type, value)
+        
+    def _concat_list(self, list, start, delimiter):
+    	if len(list) == 0:
+    		return ""
+    	elif len(list) == 1:
+    		return start +" " + list[0]
+    	else:
+    		return start + " " + reduce(lambda a,b:a+delimiter+b, list)
+    
+    # This is needed for debugging
+    def __repr__(self):
+        where_filters = [key + value for key,value in self.filters.iteritems()]
+    	where_cond = self._concat_list(where_filters, "WHERE", " AND ")
+    	order_cond = self._concat_list(self.compiler._get_ordering(), "ORDER BY", ", ")
+            
+        return '<NonrelQuery: SELECT * from %s %s %s>' % (self.db_table, where_cond, order_cond)
 
 class NonrelCompiler(SQLCompiler):
     """
                     result.append(name)
                 else:
                     result.append('-' + name)
+
         return result
 
 class NonrelInsertCompiler(object):
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.