Skip to content

Commit

Permalink
solve#368 add CURRENT_TIMESTAMP to the list of SQL functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Vachette committed Nov 18, 2022
1 parent d23f70d commit a60192a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PHPSQLParser/utils/PHPSQLParserConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PHPSQLParserConstants {
'BITLENGTH', 'CAST', 'CEILING', 'CHAR', 'CHAR_LENGTH', 'CHARACTER_LENGTH', 'CHARSET',
'COALESCE', 'COERCIBILITY', 'COLLATION', 'COMPRESS', 'CONCAT', 'CONCAT_WS',
'CONNECTION_ID', 'CONV', 'CONVERT', 'CONVERT_TZ', 'COS', 'COT', 'COUNT', 'CRC32',
'CURDATE', 'CURRENT_USER', 'CURRVAL', 'CURTIME', 'DATABASE', 'SCHEMA', 'DATE_ADD', 'DATE_DIFF',
'CURDATE', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURRVAL', 'CURTIME', 'DATABASE', 'SCHEMA', 'DATE_ADD', 'DATE_DIFF',
'DATE_FORMAT', 'DATE_SUB', 'DAY', 'DAYNAME', 'DAYOFMONTH', 'DAYOFWEEK', 'DAYOFYEAR',
'DECODE', 'DEFAULT', 'DEGREES', 'DES_DECRYPT', 'DES_ENCRYPT', 'ELT', 'ENCODE',
'ENCRYPT', 'EXP', 'EXPORT_SET', 'EXTRACT', 'FIELD', 'FIND_IN_SET', 'FLOOR', 'FORMAT',
Expand Down
30 changes: 30 additions & 0 deletions tests/cases/creator/issue368Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* issue368.php
*
* Test case for PHPSQLCreator.
*/

namespace PHPSQLParser\Test\Creator;

use PHPSQLParser\PHPSQLParser;
use PHPSQLParser\PHPSQLCreator;

class Issue368Test extends \PHPUnit\Framework\TestCase
{
/*
* https://github.com/greenlion/PHP-SQL-Parser/issues/368
* CURRENT_TIMESTAMP is detected as a reserved word an generate errors when used in JOIN clause
*/
public function testIssue368()
{
$sql = "SELECT foo FROM barTable LEFT JOIN bazTable ON barTable.a = bazTable.a AND bazTable.d <= CURRENT_TIMESTAMP"; // KO

$parser = new PHPSQLParser();
$creator = new PHPSQLCreator();

$parser->parse($sql);

$this->assertEquals($sql, $creator->create($parser->parsed));
}
}

0 comments on commit a60192a

Please sign in to comment.