diff options
-rw-r--r-- | composer.json | 6 | ||||
-rw-r--r-- | composer.lock | 195 | ||||
-rw-r--r-- | phpunit.xml | 5 | ||||
-rw-r--r-- | src/Components/SetOperation.php | 13 | ||||
-rw-r--r-- | tests/Builder/SelectStatementTest.php | 10 |
5 files changed, 162 insertions, 67 deletions
diff --git a/composer.json b/composer.json index 86fb6e3..ef89082 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,12 @@ "php": ">=5.3.0" }, "require-dev": { - "phpunit/php-code-coverage": "~2.0", - "phpunit/phpunit": "~4.0|~5.0" + "phpunit/php-code-coverage": "~3.0", + "phpunit/phpunit": "~5.1" }, "autoload": { "psr-4": { "SqlParser\\": "src" } } -}
\ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 5b71021..7885f48 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7ddc27633687cd226f5f58703d6f66ea", - "content-hash": "0f2db3469af779fee2d8342ebe96a692", + "hash": "457f267fae4959658b21a18d2a55aebd", + "content-hash": "399e9f63cfa5b2904eeccce1dadc262a", "packages": [], "packages-dev": [ { @@ -63,6 +63,48 @@ "time": "2015-06-14 21:17:01" }, { + "name": "myclabs/deep-copy", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e3abefcd7f106677fd352cd7c187d6c969aa9ddc", + "reference": "e3abefcd7f106677fd352cd7c187d6c969aa9ddc", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2015-11-07 22:20:37" + }, + { "name": "phpdocumentor/reflection-docblock", "version": "2.0.4", "source": { @@ -173,20 +215,20 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.2.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + "reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f7bb5cddf4ffe113eeb737b05241adb947b43f9d", + "reference": "f7bb5cddf4ffe113eeb737b05241adb947b43f9d", "shasum": "" }, "require": { - "php": ">=5.3.3", + "php": ">=5.6", "phpunit/php-file-iterator": "~1.3", "phpunit/php-text-template": "~1.2", "phpunit/php-token-stream": "~1.3", @@ -195,7 +237,7 @@ }, "require-dev": { "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" + "phpunit/phpunit": "~5" }, "suggest": { "ext-dom": "*", @@ -205,7 +247,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -231,7 +273,7 @@ "testing", "xunit" ], - "time": "2015-10-06 15:47:00" + "time": "2015-11-12 21:08:20" }, { "name": "phpunit/php-file-iterator", @@ -413,16 +455,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.8.16", + "version": "5.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e" + "reference": "c047ff05d2279404af9a7e89e2a7151c32c88022" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/625f8c345606ed0f3a141dfb88f4116f0e22978e", - "reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c047ff05d2279404af9a7e89e2a7151c32c88022", + "reference": "c047ff05d2279404af9a7e89e2a7151c32c88022", "shasum": "" }, "require": { @@ -431,18 +473,20 @@ "ext-pcre": "*", "ext-reflection": "*", "ext-spl": "*", - "php": ">=5.3.3", + "myclabs/deep-copy": "~1.3", + "php": ">=5.6", "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", + "phpunit/php-code-coverage": "~3.0", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", + "phpunit/phpunit-mock-objects": ">=3.0.5", "sebastian/comparator": "~1.1", "sebastian/diff": "~1.2", "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", "sebastian/global-state": "~1.0", + "sebastian/resource-operations": "~1.0", "sebastian/version": "~1.0", "symfony/yaml": "~2.1|~3.0" }, @@ -455,7 +499,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.8.x-dev" + "dev-master": "5.1.x-dev" } }, "autoload": { @@ -481,30 +525,30 @@ "testing", "xunit" ], - "time": "2015-10-23 06:48:33" + "time": "2015-12-10 07:54:54" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + "reference": "49bc700750196c04dd6bc2c4c99cb632b893836b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/49bc700750196c04dd6bc2c4c99cb632b893836b", + "reference": "49bc700750196c04dd6bc2c4c99cb632b893836b", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", + "php": ">=5.6", "phpunit/php-text-template": "~1.2", "sebastian/exporter": "~1.2" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "~5" }, "suggest": { "ext-soap": "*" @@ -512,7 +556,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -537,7 +581,7 @@ "mock", "xunit" ], - "time": "2015-10-02 06:51:40" + "time": "2015-12-08 08:47:06" }, { "name": "sebastian/comparator", @@ -605,28 +649,28 @@ }, { "name": "sebastian/diff", - "version": "1.3.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3" + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3", - "reference": "863df9687835c62aa423a22412d26fa2ebde3fd3", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "~4.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -649,24 +693,24 @@ } ], "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", + "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ "diff" ], - "time": "2015-02-22 15:13:53" + "time": "2015-12-08 07:14:41" }, { "name": "sebastian/environment", - "version": "1.3.2", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44" + "reference": "6e7133793a8e5a5714a551a8324337374be209df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44", - "reference": "6324c907ce7a52478eeeaede764f48733ef5ae44", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df", + "reference": "6e7133793a8e5a5714a551a8324337374be209df", "shasum": "" }, "require": { @@ -703,7 +747,7 @@ "environment", "hhvm" ], - "time": "2015-08-03 06:14:51" + "time": "2015-12-02 08:37:27" }, { "name": "sebastian/exporter", @@ -824,16 +868,16 @@ }, { "name": "sebastian/recursion-context", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "994d4a811bafe801fb06dccbee797863ba2792ba" + "reference": "913401df809e99e4f47b27cdd781f4a258d58791" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba", - "reference": "994d4a811bafe801fb06dccbee797863ba2792ba", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", + "reference": "913401df809e99e4f47b27cdd781f4a258d58791", "shasum": "" }, "require": { @@ -873,7 +917,49 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-06-21 08:04:50" + "time": "2015-11-11 19:50:13" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28 20:34:47" }, { "name": "sebastian/version", @@ -912,31 +998,34 @@ }, { "name": "symfony/yaml", - "version": "v2.7.6", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "eca9019c88fbe250164affd107bc8057771f3f4d" + "reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d", - "reference": "eca9019c88fbe250164affd107bc8057771f3f4d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002", + "reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": ">=5.5.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "3.0-dev" } }, "autoload": { "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -954,7 +1043,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-10-11 09:39:48" + "time": "2015-11-30 12:36:17" } ], "aliases": [], diff --git a/phpunit.xml b/phpunit.xml index 5d34349..f307622 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -32,4 +32,9 @@ <directory suffix=".php">./tests/Utils</directory> </testsuite> </testsuites> + <filter> + <whitelist processUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">src/</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file diff --git a/src/Components/SetOperation.php b/src/Components/SetOperation.php index d695fce..427f48d 100644 --- a/src/Components/SetOperation.php +++ b/src/Components/SetOperation.php @@ -85,10 +85,8 @@ class SetOperation extends Component } // No keyword is expected. - if (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_RESERVED)) { - if ($state == 0) { - break; - } + if (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($state == 0)) { + break; } if ($state === 0) { @@ -117,13 +115,6 @@ class SetOperation extends Component } } - // Last iteration was not saved. - if (!empty($expr->column)) { - $expr->column = trim($expr->column); - $expr->value = trim($expr->value); - $ret[] = $expr; - } - --$list->idx; return $ret; } diff --git a/tests/Builder/SelectStatementTest.php b/tests/Builder/SelectStatementTest.php index 58e8dc6..6aa9624 100644 --- a/tests/Builder/SelectStatementTest.php +++ b/tests/Builder/SelectStatementTest.php @@ -23,4 +23,14 @@ class SelectStatementTest extends TestCase $stmt->build() ); } + + public function testBuilderUnion() { + $parser = new Parser('SELECT 1 UNION SELECT 2'); + $stmt = $parser->statements[0]; + + $this->assertEquals( + 'SELECT 1 UNION SELECT 2 ', + $stmt->build() + ); + } } |