1394 def test_date_extraction(self): |
1394 def test_date_extraction(self): |
1395 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
1395 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
1396 '''SELECT CAST(EXTRACT(MONTH from _P.cw_creation_date) AS INTEGER) |
1396 '''SELECT CAST(EXTRACT(MONTH from _P.cw_creation_date) AS INTEGER) |
1397 FROM cw_Personne AS _P''') |
1397 FROM cw_Personne AS _P''') |
1398 |
1398 |
|
1399 def test_weekday_extraction(self): |
|
1400 self._check("Any WEEKDAY(D) WHERE P is Personne, P creation_date D", |
|
1401 '''SELECT (CAST(EXTRACT(DOW from _P.cw_creation_date) AS INTEGER) + 1) |
|
1402 FROM cw_Personne AS _P''') |
|
1403 |
1399 def test_substring(self): |
1404 def test_substring(self): |
1400 self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne", |
1405 self._check("Any SUBSTRING(N, 1, 1) WHERE P nom N, P is Personne", |
1401 '''SELECT SUBSTR(_P.cw_nom, 1, 1) |
1406 '''SELECT SUBSTR(_P.cw_nom, 1, 1) |
1402 FROM cw_Personne AS _P''') |
1407 FROM cw_Personne AS _P''') |
1403 |
1408 |
1757 FROM cw_CWUser AS _X |
1762 FROM cw_CWUser AS _X |
1758 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''') |
1763 WHERE ((YEAR(_X.cw_creation_date)=2010) OR (_X.cw_creation_date IS NULL))''') |
1759 |
1764 |
1760 def test_date_extraction(self): |
1765 def test_date_extraction(self): |
1761 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
1766 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
1762 '''SELECT MONTH(_P.cw_creation_date) |
1767 '''SELECT DATEPART(MONTH, _P.cw_creation_date) |
|
1768 FROM cw_Personne AS _P''') |
|
1769 |
|
1770 def test_weekday_extraction(self): |
|
1771 self._check("Any WEEKDAY(D) WHERE P is Personne, P creation_date D", |
|
1772 '''SELECT DATEPART(WEEKDAY, _P.cw_creation_date) |
1763 FROM cw_Personne AS _P''') |
1773 FROM cw_Personne AS _P''') |
1764 |
1774 |
1765 def test_symmetric(self): |
1775 def test_symmetric(self): |
1766 for t in self._parse(SYMMETRIC): |
1776 for t in self._parse(SYMMETRIC): |
1767 yield t |
1777 yield t |
1914 def test_date_extraction(self): |
1924 def test_date_extraction(self): |
1915 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
1925 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
1916 '''SELECT MONTH(_P.cw_creation_date) |
1926 '''SELECT MONTH(_P.cw_creation_date) |
1917 FROM cw_Personne AS _P''') |
1927 FROM cw_Personne AS _P''') |
1918 |
1928 |
|
1929 def test_weekday_extraction(self): |
|
1930 # custom impl. in cw.server.sqlutils |
|
1931 self._check("Any WEEKDAY(D) WHERE P is Personne, P creation_date D", |
|
1932 '''SELECT WEEKDAY(_P.cw_creation_date) |
|
1933 FROM cw_Personne AS _P''') |
|
1934 |
1919 def test_regexp(self): |
1935 def test_regexp(self): |
1920 self._check("Any X WHERE X login REGEXP '[0-9].*'", |
1936 self._check("Any X WHERE X login REGEXP '[0-9].*'", |
1921 '''SELECT _X.cw_eid |
1937 '''SELECT _X.cw_eid |
1922 FROM cw_CWUser AS _X |
1938 FROM cw_CWUser AS _X |
1923 WHERE _X.cw_login REGEXP [0-9].* |
1939 WHERE _X.cw_login REGEXP [0-9].* |
2070 return '\n'.join(newsql) |
2086 return '\n'.join(newsql) |
2071 |
2087 |
2072 def test_date_extraction(self): |
2088 def test_date_extraction(self): |
2073 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
2089 self._check("Any MONTH(D) WHERE P is Personne, P creation_date D", |
2074 '''SELECT EXTRACT(MONTH from _P.cw_creation_date) |
2090 '''SELECT EXTRACT(MONTH from _P.cw_creation_date) |
|
2091 FROM cw_Personne AS _P''') |
|
2092 |
|
2093 def test_weekday_extraction(self): |
|
2094 self._check("Any WEEKDAY(D) WHERE P is Personne, P creation_date D", |
|
2095 '''SELECT DAYOFWEEK(_P.cw_creation_date) |
2075 FROM cw_Personne AS _P''') |
2096 FROM cw_Personne AS _P''') |
2076 |
2097 |
2077 def test_cast(self): |
2098 def test_cast(self): |
2078 self._check("Any CAST(String, P) WHERE P is Personne", |
2099 self._check("Any CAST(String, P) WHERE P is Personne", |
2079 '''SELECT CAST(_P.cw_eid AS mediumtext) |
2100 '''SELECT CAST(_P.cw_eid AS mediumtext) |