You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect either ignore all MySQL specific comments or remove the remaining comment part from
the end of the query.
Here is full PHP unit test for this case:
publicfunctiontestMysqldump()
{
$sql = <<<SQL-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)ldump e-nocleg-2-dev 01-te---- Host: localhost Database: x-- -------------------------------------------------------- Server version 5.7.24/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8 */;/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;/*!40103 SET TIME_ZONE='+00:00' */;/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;SQL;
$expectedSql = [
'SET @OLD_CHARACTER_SET_CLIENT = @@CHARACTER_SET_CLIENT',
'SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS',
'SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION',
'SET NAMES utf8',
'SET @OLD_TIME_ZONE = @@TIME_ZONE',
"SET TIME_ZONE = '+00:00'",
'SET @OLD_UNIQUE_CHECKS = @@UNIQUE_CHECKS, UNIQUE_CHECKS = 0',
'SET @OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0',
"SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'",
'SET @OLD_SQL_NOTES = @@SQL_NOTES, SQL_NOTES = 0',
];
$parser = newParser($sql, true);
$parser->parse();
$sql = [];
foreach($parser->statementsas$stmt) {
$sql[] = $stmt->__toString();
}
$this->assertEquals($expectedSql, $sql);
}
Current result is:
Array
(
[0] => SET @OLD_CHARACTER_SET_CLIENT = @@CHARACTER_SET_CLIENT */
[1] => SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS */
[2] => SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION */
[3] => SET NAMES utf8
[4] => SET @OLD_TIME_ZONE = @@TIME_ZONE */
[5] => SET TIME_ZONE = '+00:00'
[6] => SET @OLD_UNIQUE_CHECKS = @@UNIQUE_CHECKS, UNIQUE_CHECKS = 0 */
[7] => SET @OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0 */
[8] => SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'
[9] => SET @OLD_SQL_NOTES = @@SQL_NOTES, SQL_NOTES = 0 */
)
Expected result:
Array
(
[0] => SET @OLD_CHARACTER_SET_CLIENT = @@CHARACTER_SET_CLIENT
[1] => SET @OLD_CHARACTER_SET_RESULTS = @@CHARACTER_SET_RESULTS
[2] => SET @OLD_COLLATION_CONNECTION = @@COLLATION_CONNECTION
[3] => SET NAMES utf8
[4] => SET @OLD_TIME_ZONE = @@TIME_ZONE
[5] => SET TIME_ZONE = '+00:00'
[6] => SET @OLD_UNIQUE_CHECKS = @@UNIQUE_CHECKS, UNIQUE_CHECKS = 0
[7] => SET @OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0
[8] => SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'
[9] => SET @OLD_SQL_NOTES = @@SQL_NOTES, SQL_NOTES = 0
)
The text was updated successfully, but these errors were encountered:
pszalko
changed the title
Parser leaves comment string at end the query in mysql-specific comment
Parser leaves comment string at the end of the query in mysql-specific comment
Feb 15, 2019
When parsing SQL with MySQL specific comments
/*! ... */
(https://dev.mysql.com/doc/refman/5.7/en/comments.html), parser leaves ending comment in parsed query:*/
.I would expect either ignore all MySQL specific comments or remove the remaining comment part from
the end of the query.
Here is full PHP unit test for this case:
Current result is:
Expected result:
The text was updated successfully, but these errors were encountered: