Skip to content

Commit 8a6d279

Browse files
committed
Merge branch 'svnsync'
CHG: in the UnionProcessor was a typo, it has called an invalid function CHG: the parser uses some dynamic constants, they must have a namespace CHG: some test cases have been corrected for namespace usage
2 parents c9c0e35 + 670c997 commit 8a6d279

94 files changed

Lines changed: 3590 additions & 345 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/PHPSQLParser/processors/DropProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function process($tokenList) {
7676
case 'DATABASE':
7777
case 'TABLE':
7878
if ($objectType === '') {
79-
$objectType = constant('ExpressionType::' . $upper);
79+
$objectType = constant('PHPSQLParser\utils\ExpressionType::' . $upper);
8080
}
8181
$base_expr = '';
8282
break;

src/PHPSQLParser/processors/PartitionDefinitionProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function process($tokens) {
261261
case 'INDEX':
262262
if ($prevCategory === 'PARTITION') {
263263
// followed by DIRECTORY
264-
$expr[] = array('expr_type' => constant('ExpressionType::PARTITION_' . $upper . '_DIR'),
264+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::PARTITION_' . $upper . '_DIR'),
265265
'base_expr' => false, 'sub_tree' => false,
266266
'storage' => substr($base_expr, 0, -strlen($token)));
267267

@@ -287,7 +287,7 @@ public function process($tokens) {
287287
case 'MAX_ROWS':
288288
case 'MIN_ROWS':
289289
if ($prevCategory === 'PARTITION') {
290-
$expr[] = array('expr_type' => constant('ExpressionType::PARTITION_' . $upper),
290+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::PARTITION_' . $upper),
291291
'base_expr' => false, 'sub_tree' => false,
292292
'storage' => substr($base_expr, 0, -strlen($token)));
293293

src/PHPSQLParser/processors/PartitionOptionsProcessor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function process($tokens) {
149149
case 'PARTITIONS':
150150
case 'SUBPARTITIONS':
151151
$currCategory = 'PARTITION_NUM';
152-
$expr = array('expr_type' => constant('ExpressionType::' . substr($upper, 0, -1) . '_COUNT'),
152+
$expr = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::' . substr($upper, 0, -1) . '_COUNT'),
153153
'base_expr' => false, 'sub_tree' => array($this->getReservedType($trim)),
154154
'storage' => substr($base_expr, 0, -strlen($token)));
155155
$base_expr = $token;
@@ -163,7 +163,7 @@ public function process($tokens) {
163163

164164
case 'HASH':
165165
case 'KEY':
166-
$expr[] = array('expr_type' => constant('ExpressionType::' . $prevCategory . '_' . $upper),
166+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::' . $prevCategory . '_' . $upper),
167167
'base_expr' => false, 'linear' => ($currCategory === 'LINEAR'), 'sub_tree' => false,
168168
'storage' => substr($base_expr, 0, -strlen($token)));
169169

@@ -180,7 +180,7 @@ public function process($tokens) {
180180

181181
case 'ALGORITHM':
182182
if ($currCategory === 'KEY') {
183-
$expr[] = array('expr_type' => constant('ExpressionType::' . $prevCategory . '_KEY_ALGORITHM'),
183+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::' . $prevCategory . '_KEY_ALGORITHM'),
184184
'base_expr' => false, 'sub_tree' => false,
185185
'storage' => substr($base_expr, 0, -strlen($token)));
186186

@@ -201,7 +201,7 @@ public function process($tokens) {
201201

202202
case 'RANGE':
203203
case 'LIST':
204-
$expr[] = array('expr_type' => constant('ExpressionType::PARTITION_' . $upper), 'base_expr' => false,
204+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::PARTITION_' . $upper), 'base_expr' => false,
205205
'sub_tree' => false, 'storage' => substr($base_expr, 0, -strlen($token)));
206206

207207
$last = array_pop($parsed);

src/PHPSQLParser/processors/SubpartitionDefinitionProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function process($tokens) {
185185
case 'INDEX':
186186
if ($prevCategory === 'SUBPARTITION') {
187187
// followed by DIRECTORY
188-
$expr[] = array('expr_type' => constant('ExpressionType::SUBPARTITION_' . $upper . '_DIR'),
188+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::SUBPARTITION_' . $upper . '_DIR'),
189189
'base_expr' => false, 'sub_tree' => false,
190190
'storage' => substr($base_expr, 0, -strlen($token)));
191191

@@ -211,7 +211,7 @@ public function process($tokens) {
211211
case 'MAX_ROWS':
212212
case 'MIN_ROWS':
213213
if ($prevCategory === 'SUBPARTITION') {
214-
$expr[] = array('expr_type' => constant('ExpressionType::SUBPARTITION_' . $upper),
214+
$expr[] = array('expr_type' => constant('PHPSQLParser\utils\ExpressionType::SUBPARTITION_' . $upper),
215215
'base_expr' => false, 'sub_tree' => false,
216216
'storage' => substr($base_expr, 0, -strlen($token)));
217217

src/PHPSQLParser/processors/UnionProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function processMySQLUnion($queries) {
107107
break;
108108
}
109109

110-
$queries[$unionType][$key] = $this->$processSQL($queries[$unionType][$key]);
110+
$queries[$unionType][$key] = $this->processSQL($queries[$unionType][$key]);
111111
break;
112112
}
113113
}

src/PHPSQLParser/utils/PHPSQLParserConstants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function addCustomFunction($token) {
209209

210210
public function removeCustomFunction($token) {
211211
$token = strtoupper(trim($token));
212-
unset($this->$customFunctions[$token]);
212+
unset($this->customFunctions[$token]);
213213
}
214214

215215
public function getCustomFunctions() {

tests/cases/creator/count_distinct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
$expected = getExpectedValue(dirname(__FILE__), 'distinct.sql', false);
5353
ok($created === $expected, 'count(distinct x)');
5454

55-
?>
55+
?>

tests/cases/creator/delete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
$expected = getExpectedValue(dirname(__FILE__), 'delete.sql', false);
5252
ok($created === $expected, 'a multi-table delete statement');
5353

54-
?>
54+
?>

tests/cases/creator/insert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@
6868
$expected = getExpectedValue(dirname(__FILE__), 'insert3.sql', false);
6969
ok($created === $expected, 'multiple records within INSERT (2)');
7070

71-
?>
71+
?>

tests/cases/parser/aliases.php

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
11
<?php
2-
3-
require_once dirname(__FILE__) . "/../../../src/PHPSQLParser.php";
4-
require_once dirname(__FILE__) . "/../../test-more.php";
2+
/**
3+
* aliases.php
4+
*
5+
* Test case for PHPSQLParser.
6+
*
7+
* PHP version 5
8+
*
9+
* LICENSE:
10+
* Copyright (c) 2010-2014 Justin Swanhart and André Rothe
11+
* All rights reserved.
12+
*
13+
* Redistribution and use in source and binary forms, with or without
14+
* modification, are permitted provided that the following conditions
15+
* are met:
16+
* 1. Redistributions of source code must retain the above copyright
17+
* notice, this list of conditions and the following disclaimer.
18+
* 2. Redistributions in binary form must reproduce the above copyright
19+
* notice, this list of conditions and the following disclaimer in the
20+
* documentation and/or other materials provided with the distribution.
21+
* 3. The name of the author may not be used to endorse or promote products
22+
* derived from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*
35+
* @author André Rothe <[email protected]>
36+
* @copyright 2010-2014 Justin Swanhart and André Rothe
37+
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
38+
* @version SVN: $Id$
39+
*
40+
*/
41+
namespace PHPSQLParser;
42+
require_once dirname(__FILE__) . '/../../../src/PHPSQLParser/PHPSQLParser.php';
43+
require_once dirname(__FILE__) . '/../../test-more.php';
544

645
$parser = new PHPSQLParser();
746

0 commit comments

Comments
 (0)