server/test/unittest_rql2sql.py
changeset 7257 beea955b45e2
parent 7256 ccd44caeb936
child 7359 40490b9e0a6e
equal deleted inserted replaced
7256:ccd44caeb936 7257:beea955b45e2
  1334     def test_cast(self):
  1334     def test_cast(self):
  1335         self._check("Any CAST(String, P) WHERE P is Personne",
  1335         self._check("Any CAST(String, P) WHERE P is Personne",
  1336                     '''SELECT CAST(_P.cw_eid AS text)
  1336                     '''SELECT CAST(_P.cw_eid AS text)
  1337 FROM cw_Personne AS _P''')
  1337 FROM cw_Personne AS _P''')
  1338 
  1338 
       
  1339     def test_regexp(self):
       
  1340         self._check("Any X WHERE X login REGEXP '[0-9].*'",
       
  1341                     '''SELECT _X.cw_eid
       
  1342 FROM cw_CWUser AS _X
       
  1343 WHERE _X.cw_login ~ [0-9].*
       
  1344 ''')
       
  1345 
  1339     def test_parser_parse(self):
  1346     def test_parser_parse(self):
  1340         for t in self._parse(PARSER):
  1347         for t in self._parse(PARSER):
  1341             yield t
  1348             yield t
  1342 
  1349 
  1343     def test_basic_parse(self):
  1350     def test_basic_parse(self):
  1633 
  1640 
  1634     def test_has_text(self):
  1641     def test_has_text(self):
  1635         for t in self._parse(HAS_TEXT_LG_INDEXER):
  1642         for t in self._parse(HAS_TEXT_LG_INDEXER):
  1636             yield t
  1643             yield t
  1637 
  1644 
       
  1645     def test_regexp(self):
       
  1646         self.skipTest('regexp-based pattern matching not implemented in sqlserver')
       
  1647 
  1638     def test_or_having_fake_terms(self):
  1648     def test_or_having_fake_terms(self):
  1639         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1649         self._check('Any X WHERE X is CWUser, X creation_date D HAVING YEAR(D) = "2010" OR D = NULL',
  1640                     '''SELECT _X.cw_eid
  1650                     '''SELECT _X.cw_eid
  1641 FROM cw_CWUser AS _X
  1651 FROM cw_CWUser AS _X
  1642 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  1652 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''')
  1746     def test_date_extraction(self):
  1756     def test_date_extraction(self):
  1747         self._check("Any MONTH(D) WHERE P is Personne, P creation_date D",
  1757         self._check("Any MONTH(D) WHERE P is Personne, P creation_date D",
  1748                     '''SELECT MONTH(_P.cw_creation_date)
  1758                     '''SELECT MONTH(_P.cw_creation_date)
  1749 FROM cw_Personne AS _P''')
  1759 FROM cw_Personne AS _P''')
  1750 
  1760 
       
  1761     def test_regexp(self):
       
  1762         self._check("Any X WHERE X login REGEXP '[0-9].*'",
       
  1763                     '''SELECT _X.cw_eid
       
  1764 FROM cw_CWUser AS _X
       
  1765 WHERE _X.cw_login REGEXP [0-9].*
       
  1766 ''')
       
  1767 
       
  1768 
  1751     def test_union(self):
  1769     def test_union(self):
  1752         for t in self._parse((
  1770         for t in self._parse((
  1753             ('(Any N ORDERBY 1 WHERE X name N, X is State)'
  1771             ('(Any N ORDERBY 1 WHERE X name N, X is State)'
  1754              ' UNION '
  1772              ' UNION '
  1755              '(Any NN ORDERBY 1 WHERE XX name NN, XX is Transition)',
  1773              '(Any NN ORDERBY 1 WHERE XX name NN, XX is Transition)',
  1890 
  1908 
  1891     def test_cast(self):
  1909     def test_cast(self):
  1892         self._check("Any CAST(String, P) WHERE P is Personne",
  1910         self._check("Any CAST(String, P) WHERE P is Personne",
  1893                     '''SELECT CAST(_P.cw_eid AS mediumtext)
  1911                     '''SELECT CAST(_P.cw_eid AS mediumtext)
  1894 FROM cw_Personne AS _P''')
  1912 FROM cw_Personne AS _P''')
       
  1913 
       
  1914     def test_regexp(self):
       
  1915         self._check("Any X WHERE X login REGEXP '[0-9].*'",
       
  1916                     '''SELECT _X.cw_eid
       
  1917 FROM cw_CWUser AS _X
       
  1918 WHERE _X.cw_login REGEXP [0-9].*
       
  1919 ''')
  1895 
  1920 
  1896     def test_from_clause_needed(self):
  1921     def test_from_clause_needed(self):
  1897         queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')",
  1922         queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')",
  1898                     '''SELECT 1
  1923                     '''SELECT 1
  1899 FROM (SELECT 1) AS _T
  1924 FROM (SELECT 1) AS _T