diff options
author | William Desportes <williamdes@wdes.fr> | 2019-12-31 20:25:11 +0100 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2019-12-31 20:26:06 +0100 |
commit | e61b53701a72d4454e5ffa644d7ac86f976ee65b (patch) | |
tree | 38d98b9c0c3be8c066a737078065ca95c7a17395 | |
parent | 8a9b8fcd3357fbf42756519bcea7ef3ca668aaf5 (diff) | |
parent | f14d9a8d6bd75ab89c4ac19d4b7fef0a218951ec (diff) | |
download | sql-parser-e61b53701a72d4454e5ffa644d7ac86f976ee65b.zip sql-parser-e61b53701a72d4454e5ffa644d7ac86f976ee65b.tar.gz sql-parser-e61b53701a72d4454e5ffa644d7ac86f976ee65b.tar.bz2 |
Merge #279 - fix php error undefined index
Pull-request: #279
Fixes: #249
Signed-off-by: William Desportes <williamdes@wdes.fr>
-rw-r--r-- | src/Utils/Query.php | 2 | ||||
-rw-r--r-- | tests/Utils/QueryTest.php | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/Utils/Query.php b/src/Utils/Query.php index 2e623aa..9494d96 100644 --- a/src/Utils/Query.php +++ b/src/Utils/Query.php @@ -591,7 +591,7 @@ class Query * * @var int */ - $clauseIdx = $clauses[$clauseType]; + $clauseIdx = isset($clauses[$clauseType]) ? $clauses[$clauseType] : -1; $firstClauseIdx = $clauseIdx; $lastClauseIdx = $clauseIdx; diff --git a/tests/Utils/QueryTest.php b/tests/Utils/QueryTest.php index 3bc1783..f4676ec 100644 --- a/tests/Utils/QueryTest.php +++ b/tests/Utils/QueryTest.php @@ -598,6 +598,20 @@ class QueryTest extends TestCase ); } + public function testReplaceNonExistingPart() + { + $parser = new Parser('ALTER TABLE `sale_mast` OPTIMIZE PARTITION p3'); + $this->assertEquals( + ' ALTER TABLE `sale_mast` OPTIMIZE PARTITION p3', + Query::replaceClause( + $parser->statements[0], + $parser->list, + 'ORDER BY', + '' + ) + ); + } + public function testReplaceClauses() { $this->assertEquals('', Query::replaceClauses(null, null, array())); |