server/test/unittest_rql2sql.py
changeset 7672 f31f9882c90f
parent 7651 7c0af7ef3325
child 7705 2a1f078ebdcd
equal deleted inserted replaced
7671:d911a73ac8c5 7672:f31f9882c90f
  1641     def test_concat_string(self):
  1641     def test_concat_string(self):
  1642         self._check('Any "A"+R WHERE X ref R',
  1642         self._check('Any "A"+R WHERE X ref R',
  1643                     '''SELECT (A || _X.cw_ref)
  1643                     '''SELECT (A || _X.cw_ref)
  1644 FROM cw_Affaire AS _X''')
  1644 FROM cw_Affaire AS _X''')
  1645 
  1645 
  1646     def test_or_having_fake_terms(self):
  1646     def test_or_having_fake_terms_base(self):
  1647         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1647         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1648                     '''SELECT _X.cw_eid
  1648                     '''SELECT _X.cw_eid
  1649 FROM cw_CWUser AS _X
  1649 FROM cw_CWUser AS _X
  1650 WHERE ((CAST(EXTRACT(YEAR from _X.cw_creation_date) AS INTEGER)=2010) OR (_X.cw_creation_date IS NULL))''')
  1650 WHERE ((CAST(EXTRACT(YEAR from _X.cw_creation_date) AS INTEGER)=2010) OR (_X.cw_creation_date IS NULL))''')
       
  1651 
       
  1652     def test_or_having_fake_terms_exists(self):
       
  1653         # crash with rql <= 0.29.0
       
  1654         self._check('Any X WHERE X is CWUser, EXISTS(B bookmarked_by X, B creation_date D) HAVING D=2010 OR D=NULL, D=1 OR D=NULL',
       
  1655                     '''SELECT _X.cw_eid
       
  1656 FROM cw_CWUser AS _X
       
  1657 WHERE EXISTS(SELECT 1 FROM bookmarked_by_relation AS rel_bookmarked_by0, cw_Bookmark AS _B WHERE rel_bookmarked_by0.eid_from=_B.cw_eid AND rel_bookmarked_by0.eid_to=_X.cw_eid AND ((_B.cw_creation_date=1) OR (_B.cw_creation_date IS NULL)) AND ((_B.cw_creation_date=2010) OR (_B.cw_creation_date IS NULL)))''')
       
  1658 
       
  1659     def test_or_having_fake_terms_nocrash(self):
       
  1660         # crash with rql <= 0.29.0
       
  1661         self._check('Any X WHERE X is CWUser, X creation_date D HAVING D=2010 OR D=NULL, D=1 OR D=NULL',
       
  1662                     '''SELECT _X.cw_eid
       
  1663 FROM cw_CWUser AS _X
       
  1664 WHERE ((_X.cw_creation_date=1) OR (_X.cw_creation_date IS NULL)) AND ((_X.cw_creation_date=2010) OR (_X.cw_creation_date IS NULL))''')
  1651 
  1665 
  1652     def test_not_no_where(self):
  1666     def test_not_no_where(self):
  1653         # XXX will check if some in_group relation exists, that's it.
  1667         # XXX will check if some in_group relation exists, that's it.
  1654         # We  can't actually know if we want to check if there are some
  1668         # We  can't actually know if we want to check if there are some
  1655         # X without in_group relation, or some G without it.
  1669         # X without in_group relation, or some G without it.
  1697             yield t
  1711             yield t
  1698 
  1712 
  1699     def test_regexp(self):
  1713     def test_regexp(self):
  1700         self.skipTest('regexp-based pattern matching not implemented in sqlserver')
  1714         self.skipTest('regexp-based pattern matching not implemented in sqlserver')
  1701 
  1715 
  1702     def test_or_having_fake_terms(self):
  1716     def test_or_having_fake_terms_base(self):
  1703         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1717         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1704                     '''SELECT _X.cw_eid
  1718                     '''SELECT _X.cw_eid
  1705 FROM cw_CWUser AS _X
  1719 FROM cw_CWUser AS _X
  1706 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  1720 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  1707 
  1721 
  1982 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""),
  1996 WHERE appears0.word_id IN (SELECT word_id FROM word WHERE word in ('toto', 'tata'))"""),
  1983             )):
  1997             )):
  1984             yield t
  1998             yield t
  1985 
  1999 
  1986 
  2000 
  1987     def test_or_having_fake_terms(self):
  2001     def test_or_having_fake_terms_base(self):
  1988         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  2002         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1989                     '''SELECT _X.cw_eid
  2003                     '''SELECT _X.cw_eid
  1990 FROM cw_CWUser AS _X
  2004 FROM cw_CWUser AS _X
  1991 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  2005 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  1992 
  2006 
  2093         self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne",
  2107         self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne",
  2094                     '''SELECT SUBSTRING(_P.cw_nom, 1, 1)
  2108                     '''SELECT SUBSTRING(_P.cw_nom, 1, 1)
  2095 FROM cw_Personne AS _P''')
  2109 FROM cw_Personne AS _P''')
  2096 
  2110 
  2097 
  2111 
  2098     def test_or_having_fake_terms(self):
  2112     def test_or_having_fake_terms_base(self):
  2099         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  2113         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  2100                     '''SELECT _X.cw_eid
  2114                     '''SELECT _X.cw_eid
  2101 FROM cw_CWUser AS _X
  2115 FROM cw_CWUser AS _X
  2102 WHERE ((EXTRACT(YEAR from _X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  2116 WHERE ((EXTRACT(YEAR from _X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  2103 
  2117