server/test/unittest_rql2sql.py
branchstable
changeset 5887 3f55f0f10a22
parent 5886 00a78298d30d
child 5890 141b935a38fc
child 5898 5630bd8f98d9
equal deleted inserted replaced
5886:00a78298d30d 5887:3f55f0f10a22
  1428     def test_concat_string(self):
  1428     def test_concat_string(self):
  1429         self._check('Any "A"+R WHERE X ref R',
  1429         self._check('Any "A"+R WHERE X ref R',
  1430                     '''SELECT (A || _X.cw_ref)
  1430                     '''SELECT (A || _X.cw_ref)
  1431 FROM cw_Affaire AS _X''')
  1431 FROM cw_Affaire AS _X''')
  1432 
  1432 
       
  1433     def test_or_having_fake_terms(self):
       
  1434         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
       
  1435                     '''SELECT _X.cw_eid
       
  1436 FROM cw_CWUser AS _X
       
  1437 WHERE ((CAST(EXTRACT(YEAR from _X.cw_creation_date) AS INTEGER)=2010) OR (_X.cw_creation_date IS NULL))''')
       
  1438 
  1433 
  1439 
  1434 class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC):
  1440 class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC):
  1435 
  1441 
  1436     def setUp(self):
  1442     def setUp(self):
  1437         RQLGeneratorTC.setUp(self)
  1443         RQLGeneratorTC.setUp(self)
  1534 FROM appears AS appears0, cw_Folder AS _X
  1540 FROM appears AS appears0, cw_Folder AS _X
  1535 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu
  1541 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata')) AND appears0.uid=_X.cw_eid AND _X.cw_name=tutu
  1536 """),
  1542 """),
  1537             )):
  1543             )):
  1538             yield t
  1544             yield t
       
  1545 
       
  1546 
       
  1547     def test_or_having_fake_terms(self):
       
  1548         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
       
  1549                     '''SELECT _X.cw_eid
       
  1550 FROM cw_CWUser AS _X
       
  1551 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  1539 
  1552 
  1540 
  1553 
  1541 
  1554 
  1542 class MySQLGenerator(PostgresSQLGeneratorTC):
  1555 class MySQLGenerator(PostgresSQLGeneratorTC):
  1543 
  1556 
  1621     def test_substring(self):
  1634     def test_substring(self):
  1622         self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne",
  1635         self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne",
  1623                     '''SELECT SUBSTRING(_P.cw_nom, 1, 1)
  1636                     '''SELECT SUBSTRING(_P.cw_nom, 1, 1)
  1624 FROM cw_Personne AS _P''')
  1637 FROM cw_Personne AS _P''')
  1625 
  1638 
       
  1639 
       
  1640     def test_or_having_fake_terms(self):
       
  1641         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
       
  1642                     '''SELECT _X.cw_eid
       
  1643 FROM cw_CWUser AS _X
       
  1644 WHERE ((EXTRACT(YEAR from _X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
       
  1645 
       
  1646 
  1626 class removeUnsusedSolutionsTC(TestCase):
  1647 class removeUnsusedSolutionsTC(TestCase):
  1627     def test_invariant_not_varying(self):
  1648     def test_invariant_not_varying(self):
  1628         rqlst = mock_object(defined_vars={})
  1649         rqlst = mock_object(defined_vars={})
  1629         rqlst.defined_vars['A'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=True)
  1650         rqlst.defined_vars['A'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=True)
  1630         rqlst.defined_vars['B'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=False)
  1651         rqlst.defined_vars['B'] = mock_object(scope=rqlst, stinfo={}, _q_invariant=False)