diff --git a/src/alasqlparser.jison b/src/alasqlparser.jison index 7bfa7d8d7..f2e1a47b4 100755 --- a/src/alasqlparser.jison +++ b/src/alasqlparser.jison @@ -113,7 +113,7 @@ COLUMNS return 'COLUMN' DATABASE(S)? return 'DATABASE' 'DAY' return 'DAY' 'DAYOFMONTH' return 'DAY' -'DAYOFYEAR' return 'DAYOFYEAR' +'DAYOFYEAR' return 'DAY' 'DATEADD' return 'DATEADD' 'DATEDIFF' return 'DATEDIFF' 'DAYOFWEEK' return 'DAYOFWEEK' diff --git a/src/alasqlparser.js b/src/alasqlparser.js index 7653b4683..0d4f69901 100755 --- a/src/alasqlparser.js +++ b/src/alasqlparser.js @@ -2615,7 +2615,7 @@ case 83:return 123 break; case 84:return 123 break; -case 85:return 125 +case 85:return 123 break; case 86:return 308 break; diff --git a/test/test1979.js b/test/test1979.js index b785a7e34..27fc792dd 100644 --- a/test/test1979.js +++ b/test/test1979.js @@ -78,19 +78,22 @@ describe('Test ' + test + ' - date function aliases in the parser', function () assert.throws(function() { alasql('SELECT DAYOFWEEK(NOW()) AS DAYOFWEEK'); }); + assert.throws(function() { + alasql('SELECT DAYOFMONTH(NOW()) AS DAYOFMONTH'); + }); assert.throws(function() { alasql('SELECT MONTH(NOW()) AS MONTH'); }); assert.throws(function() { alasql('SELECT YEAR(NOW()) AS YEAR'); }); - // As literal is fine alasql("SELECT SECOND(NOW()) AS 'SECOND'"); alasql("SELECT HOUR(NOW()) AS 'HOUR'"); alasql("SELECT MINUTE(NOW()) AS 'MINUTE'"); alasql("SELECT DAY(NOW()) AS 'DAY'"); alasql("SELECT DAYOFWEEK(NOW()) AS 'DAYOFWEEK'"); + alasql("SELECT DAYOFMONTH(NOW()) AS 'DAYOFMONTH'"); alasql("SELECT MONTH(NOW()) AS 'MONTH'"); alasql("SELECT YEAR(NOW()) AS 'YEAR'"); }); @@ -120,5 +123,13 @@ describe('Test ' + test + ' - date function aliases in the parser', function () // Verify it subtracted 10 days from 20081012 assert.equal(2, alasql('SELECT DATE_SUB(DATE("20081012"), INTERVAL 10 DAY) AS a')[0].a.getDate()); assert.equal(2, alasql('SELECT SUBDATE(DATE("20081012"), INTERVAL 10 DAY) AS a')[0].a.getDate()); + + // Assert DAYOFYEAR + assert.equal(107, alasql('SELECT SUBDATE(DATE("20080101"), INTERVAL 10 DAYOFYEAR) AS a')[0].a.getYear()); + + // Assert that nonexistinginterval throws + assert.throws(function() { + alasql('SELECT ADDDATE(DATE("20081012"), INTERVAL 10 nonexistinginterval) AS a'); + }); }); });