move escape_user_sql() to the manager class, where it better belongs, make it not static, since it doesn't need to be and we need to override it, and override it in TestViewManager to specify the table whenever test_idx is used (otherwise it can be an ambiguous reference when test_attributes is joined)

Signed-off-by: Steve Howard <showard@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@2995 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/new_tko/tko/models.py b/new_tko/tko/models.py
index 27b02a9..36f1548 100644
--- a/new_tko/tko/models.py
+++ b/new_tko/tko/models.py
@@ -385,6 +385,11 @@
         return [row[0] for row in rows if row[0] is not None]
 
 
+    def escape_user_sql(self, sql):
+        sql = super(TestViewManager, self).escape_user_sql(sql)
+        return sql.replace('test_idx', self.get_key_on_this_table('test_idx'))
+
+
 class TestView(dbmodels.Model, model_logic.ModelExtensions):
     extra_fields = {
         'DATE(test_finished_time)' : 'test finished day',