Skip to content

Commit a60192a

Browse files
author
Marc Vachette
committed
solve#368 add CURRENT_TIMESTAMP to the list of SQL functions
1 parent d23f70d commit a60192a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/PHPSQLParser/utils/PHPSQLParserConstants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class PHPSQLParserConstants {
129129
'BITLENGTH', 'CAST', 'CEILING', 'CHAR', 'CHAR_LENGTH', 'CHARACTER_LENGTH', 'CHARSET',
130130
'COALESCE', 'COERCIBILITY', 'COLLATION', 'COMPRESS', 'CONCAT', 'CONCAT_WS',
131131
'CONNECTION_ID', 'CONV', 'CONVERT', 'CONVERT_TZ', 'COS', 'COT', 'COUNT', 'CRC32',
132-
'CURDATE', 'CURRENT_USER', 'CURRVAL', 'CURTIME', 'DATABASE', 'SCHEMA', 'DATE_ADD', 'DATE_DIFF',
132+
'CURDATE', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURRVAL', 'CURTIME', 'DATABASE', 'SCHEMA', 'DATE_ADD', 'DATE_DIFF',
133133
'DATE_FORMAT', 'DATE_SUB', 'DAY', 'DAYNAME', 'DAYOFMONTH', 'DAYOFWEEK', 'DAYOFYEAR',
134134
'DECODE', 'DEFAULT', 'DEGREES', 'DES_DECRYPT', 'DES_ENCRYPT', 'ELT', 'ENCODE',
135135
'ENCRYPT', 'EXP', 'EXPORT_SET', 'EXTRACT', 'FIELD', 'FIND_IN_SET', 'FLOOR', 'FORMAT',

tests/cases/creator/issue368Test.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* issue368.php
4+
*
5+
* Test case for PHPSQLCreator.
6+
*/
7+
8+
namespace PHPSQLParser\Test\Creator;
9+
10+
use PHPSQLParser\PHPSQLParser;
11+
use PHPSQLParser\PHPSQLCreator;
12+
13+
class Issue368Test extends \PHPUnit\Framework\TestCase
14+
{
15+
/*
16+
* https://github.com/greenlion/PHP-SQL-Parser/issues/368
17+
* CURRENT_TIMESTAMP is detected as a reserved word an generate errors when used in JOIN clause
18+
*/
19+
public function testIssue368()
20+
{
21+
$sql = "SELECT foo FROM barTable LEFT JOIN bazTable ON barTable.a = bazTable.a AND bazTable.d <= CURRENT_TIMESTAMP"; // KO
22+
23+
$parser = new PHPSQLParser();
24+
$creator = new PHPSQLCreator();
25+
26+
$parser->parse($sql);
27+
28+
$this->assertEquals($sql, $creator->create($parser->parsed));
29+
}
30+
}

0 commit comments

Comments
 (0)