server/test/unittest_rql2sql.py
changeset 7256 ccd44caeb936
parent 7252 adb1673efa5f
child 7257 beea955b45e2
equal deleted inserted replaced
7253:68b9e21efa63 7256:ccd44caeb936
  1329     def test_substring(self):
  1329     def test_substring(self):
  1330         self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne",
  1330         self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne",
  1331                     '''SELECT SUBSTR(_P.cw_nom, 1, 1)
  1331                     '''SELECT SUBSTR(_P.cw_nom, 1, 1)
  1332 FROM cw_Personne AS _P''')
  1332 FROM cw_Personne AS _P''')
  1333 
  1333 
       
  1334     def test_cast(self):
       
  1335         self._check("Any CAST(String, P) WHERE P is Personne",
       
  1336                     '''SELECT CAST(_P.cw_eid AS text)
       
  1337 FROM cw_Personne AS _P''')
       
  1338 
  1334     def test_parser_parse(self):
  1339     def test_parser_parse(self):
  1335         for t in self._parse(PARSER):
  1340         for t in self._parse(PARSER):
  1336             yield t
  1341             yield t
  1337 
  1342 
  1338     def test_basic_parse(self):
  1343     def test_basic_parse(self):
  1724 ORDER BY 4 DESC'''),
  1729 ORDER BY 4 DESC'''),
  1725             ]
  1730             ]
  1726         for t in self._parse(WITH_LIMIT):# + ADVANCED_WITH_LIMIT_OR_ORDERBY):
  1731         for t in self._parse(WITH_LIMIT):# + ADVANCED_WITH_LIMIT_OR_ORDERBY):
  1727             yield t
  1732             yield t
  1728 
  1733 
       
  1734     def test_cast(self):
       
  1735         self._check("Any CAST(String, P) WHERE P is Personne",
       
  1736                     '''SELECT CAST(_P.cw_eid AS nvarchar(max))
       
  1737 FROM cw_Personne AS _P''')
  1729 
  1738 
  1730 
  1739 
  1731 class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC):
  1740 class SqliteSQLGeneratorTC(PostgresSQLGeneratorTC):
  1732     backend = 'sqlite'
  1741     backend = 'sqlite'
  1733 
  1742 
  1875         return '\n'.join(newsql)
  1884         return '\n'.join(newsql)
  1876 
  1885 
  1877     def test_date_extraction(self):
  1886     def test_date_extraction(self):
  1878         self._check("Any MONTH(D) WHERE P is Personne, P creation_date D",
  1887         self._check("Any MONTH(D) WHERE P is Personne, P creation_date D",
  1879                     '''SELECT EXTRACT(MONTH from _P.cw_creation_date)
  1888                     '''SELECT EXTRACT(MONTH from _P.cw_creation_date)
       
  1889 FROM cw_Personne AS _P''')
       
  1890 
       
  1891     def test_cast(self):
       
  1892         self._check("Any CAST(String, P) WHERE P is Personne",
       
  1893                     '''SELECT CAST(_P.cw_eid AS mediumtext)
  1880 FROM cw_Personne AS _P''')
  1894 FROM cw_Personne AS _P''')
  1881 
  1895 
  1882     def test_from_clause_needed(self):
  1896     def test_from_clause_needed(self):
  1883         queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')",
  1897         queries = [("Any 1 WHERE EXISTS(T is CWGroup, T name 'managers')",
  1884                     '''SELECT 1
  1898                     '''SELECT 1