Skip to content

Commit e61b537

Browse files
committed
Merge #279 - fix php error undefined index
Pull-request: #279 Fixes: #249 Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents 8a9b8fc + f14d9a8 commit e61b537

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Utils/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ public static function getClause($statement, $list, $clause, $type = 0, $skipFir
591591
*
592592
* @var int
593593
*/
594-
$clauseIdx = $clauses[$clauseType];
594+
$clauseIdx = isset($clauses[$clauseType]) ? $clauses[$clauseType] : -1;
595595

596596
$firstClauseIdx = $clauseIdx;
597597
$lastClauseIdx = $clauseIdx;

tests/Utils/QueryTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,20 @@ public function testReplaceClauseOnlyKeyword()
598598
);
599599
}
600600

601+
public function testReplaceNonExistingPart()
602+
{
603+
$parser = new Parser('ALTER TABLE `sale_mast` OPTIMIZE PARTITION p3');
604+
$this->assertEquals(
605+
' ALTER TABLE `sale_mast` OPTIMIZE PARTITION p3',
606+
Query::replaceClause(
607+
$parser->statements[0],
608+
$parser->list,
609+
'ORDER BY',
610+
''
611+
)
612+
);
613+
}
614+
601615
public function testReplaceClauses()
602616
{
603617
$this->assertEquals('', Query::replaceClauses(null, null, array()));

0 commit comments

Comments
 (0)