{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/dbal/issues/2330","repository_url":"https://api.github.com/repos/doctrine/dbal","labels_url":"https://api.github.com/repos/doctrine/dbal/issues/2330/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/dbal/issues/2330/comments","events_url":"https://api.github.com/repos/doctrine/dbal/issues/2330/events","html_url":"https://github.com/doctrine/dbal/issues/2330","id":137524556,"number":2330,"title":"doctrine \\Doctrine\\DBAL\\Query\\QueryBuilder getSQL crash","user":{"login":"shengjie","id":2143339,"avatar_url":"https://avatars.githubusercontent.com/u/2143339?v=3","gravatar_id":"","url":"https://api.github.com/users/shengjie","html_url":"https://github.com/shengjie","followers_url":"https://api.github.com/users/shengjie/followers","following_url":"https://api.github.com/users/shengjie/following{/other_user}","gists_url":"https://api.github.com/users/shengjie/gists{/gist_id}","starred_url":"https://api.github.com/users/shengjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shengjie/subscriptions","organizations_url":"https://api.github.com/users/shengjie/orgs","repos_url":"https://api.github.com/users/shengjie/repos","events_url":"https://api.github.com/users/shengjie/events{/privacy}","received_events_url":"https://api.github.com/users/shengjie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/doctrine/dbal/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/doctrine/dbal/labels/Missing%20Tests","name":"Missing Tests","color":"eb6420"},{"url":"https://api.github.com/repos/doctrine/dbal/labels/PostgreSQL","name":"PostgreSQL","color":"c7def8"},{"url":"https://api.github.com/repos/doctrine/dbal/labels/Query","name":"Query","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-01T09:51:15Z","updated_at":"2016-03-02T09:44:45Z","closed_at":null,"body":"Hello, I've a problem while using QueryBuilder.\r\n\r\nFollowing code crashed and nginx served a 502 bad gateway.\r\n\r\n```php\r\n$qb = $sqlConnection->createQueryBuilder();\r\n$qb->select('u')->from('User', 'u')->where('u.id = 1')->andWhere('u.email is not null');\r\necho $qb->getSQL();\r\n```\r\n\r\nDoctrine/DBAL: v2.4.5\r\nPHP: 7.0.3\r\n\r\nI've investigate a little, found crash happens in `(string) $this->sqlParts['where']` (\\Doctrine\\DBAL\\Query\\QueryBuilder:1022)\r\nwhich calls:\r\n\r\n`\\Doctrine\\DBAL\\Query\\Expression\\CompositeExpression::__toString`\r\n\r\nI've put following code\r\n```php\r\n/**\r\n     * Retrieves the string representation of this composite expression.\r\n     *\r\n     * @return string\r\n     */\r\n    public function __toString()\r\n    {\r\n        if (count($this->parts) === 1) {\r\n            return (string) $this->parts[0];\r\n        }\r\n        //MY TEST CODE\r\n        echo $this->parts[0];\r\n        echo $this->parts[1]==$this ? \"true\": \"false\";\r\n        die();\r\n        //END MY TEST CODE\r\n\r\n        return '(' . implode(') ' . $this->type . ' (', $this->parts) . ')';\r\n    }\r\n```\r\n\r\nresult: `u.id = 1true`\r\n\r\n\r\nso i think this is a circular reference problem.\r\n\r\nDid i used the query builder wrong ? or is it fixed in a newer version ?\r\n\r\nThanks for any help :)"},"comment":{"url":"https://api.github.com/repos/doctrine/dbal/issues/comments/191159014","html_url":"https://github.com/doctrine/dbal/issues/2330#issuecomment-191159014","issue_url":"https://api.github.com/repos/doctrine/dbal/issues/2330","id":191159014,"user":{"login":"shengjie","id":2143339,"avatar_url":"https://avatars.githubusercontent.com/u/2143339?v=3","gravatar_id":"","url":"https://api.github.com/users/shengjie","html_url":"https://github.com/shengjie","followers_url":"https://api.github.com/users/shengjie/followers","following_url":"https://api.github.com/users/shengjie/following{/other_user}","gists_url":"https://api.github.com/users/shengjie/gists{/gist_id}","starred_url":"https://api.github.com/users/shengjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shengjie/subscriptions","organizations_url":"https://api.github.com/users/shengjie/orgs","repos_url":"https://api.github.com/users/shengjie/repos","events_url":"https://api.github.com/users/shengjie/events{/privacy}","received_events_url":"https://api.github.com/users/shengjie/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T09:44:45Z","updated_at":"2016-03-02T09:44:45Z","body":"```\r\nshengjie@MacBook-Pro-de-Shengjie:~/dbal$ git status\r\nHEAD detached at v2.4.5\r\nUntracked files:\r\n  (use \"git add <file>...\" to include in what will be committed)\r\n\r\n\tmysql.phpunit.xml\r\n\tphpunit\r\n\r\nnothing added to commit but untracked files present (use \"git add\" to track)\r\n```\r\n\r\n```\r\nshengjie@MacBook-Pro-de-Shengjie:~/dbal$ ./phpunit -c mysql.phpunit.xml tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php \r\nPHPUnit 3.7.24 by Sebastian Bergmann.\r\n\r\nConfiguration read from /Users/shengjie/dbal/mysql.phpunit.xml\r\n\r\n......Segmentation fault: 11\r\n```"}}