Commits

thatch  committed 6e43b78

Fix #7165 to make the tests work with older sqlite

  • Participants
  • Parent commits 4ac27d5
  • Branches trunk

Comments (0)

Files changed (1)

File trac/ticket/tests/query.py

 from trac.ticket.query import Query, QueryModule
 from trac.web.href import Href
 from trac.wiki.formatter import LinkFormatter
+from trac.db.sqlite_backend import sqlite_version
 
 import unittest
 import difflib
 
+if sqlite_version < 30203:
+    EXPECTED_VAL = "1*priority.value"
+else:
+    EXPECTED_VAL = "CAST(priority.value AS int)"
 
 class QueryTestCase(unittest.TestCase):
 
 """SELECT t.id AS id,t.summary AS summary,t.owner AS owner,t.type AS type,t.status AS status,t.priority AS priority,t.milestone AS milestone,t.time AS time,t.changetime AS changetime,priority.value AS priority_value
 FROM ticket AS t
   LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority)
-ORDER BY COALESCE(priority.value,'')='',CAST(priority.value AS int),t.id""")
+ORDER BY COALESCE(priority.value,'')='',""" + EXPECTED_VAL + """,t.id""")
         self.assertEqual([], args)
         tickets = query.execute(self.req)
 
 """SELECT t.id AS id,t.summary AS summary,t.owner AS owner,t.type AS type,t.status AS status,t.priority AS priority,t.milestone AS milestone,t.time AS time,t.changetime AS changetime,priority.value AS priority_value
 FROM ticket AS t
   LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority)
-ORDER BY COALESCE(priority.value,'')='' DESC,CAST(priority.value AS int) DESC,t.id""")
+ORDER BY COALESCE(priority.value,'')='' DESC,""" + EXPECTED_VAL + """ DESC,t.id""")
         self.assertEqual([], args)
         tickets = query.execute(self.req)
 
 """SELECT t.id AS id,t.summary AS summary,t.owner AS owner,t.type AS type,t.status AS status,t.milestone AS milestone,t.component AS component,t.priority AS priority,t.time AS time,t.changetime AS changetime,priority.value AS priority_value
 FROM ticket AS t
   LEFT OUTER JOIN enum AS priority ON (priority.type='priority' AND priority.name=priority)
-ORDER BY COALESCE(priority.value,'')='',CAST(priority.value AS int),t.id""")
+ORDER BY COALESCE(priority.value,'')='',""" + EXPECTED_VAL + """,t.id""")
         self.assertEqual([], args)
         tickets = query.execute(self.req)