forked from greenlion/PHP-SQL-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Handle TRUNCATE() function and TRUNCATE keyword. Issue greenlion…
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace parser; | ||
|
||
use PHPSQLParser\PHPSQLParser; | ||
|
||
class issue338Test extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testIssue338() { | ||
$sql = "SELECT id, date, type as type, libelle as libelle, TRUNCATE(debit, 2) as debit, ROUND(COALESCE(credit, 0) - COALESCE(debit, 0), 2) as solde FROM compte_cp"; | ||
|
||
$parser = new PHPSQLParser(); | ||
|
||
$parser->parse($sql, true); | ||
$parsed = $parser->parsed; | ||
|
||
$this->assertNotFalse($parsed); | ||
$this->assertTrue(is_array($parsed)); | ||
$this->assertTrue(!array_key_exists('TRUNCATE', $parsed)); | ||
|
||
$sql = "TRUNCATE TABLE truncate_table"; | ||
$parser->parse($sql, true); | ||
$parsed = $parser->parsed; | ||
|
||
$this->assertNotFalse($parsed); | ||
$this->assertTrue(is_array($parsed)); | ||
$this->assertTrue(array_key_exists('TRUNCATE', $parsed)); | ||
} | ||
|
||
} |