{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/15653","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/15653/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/15653/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/15653/events","html_url":"https://github.com/yiisoft/yii2/issues/15653","id":297783804,"number":15653,"title":"join relation override inherit where","user":{"login":"nadar","id":3417221,"avatar_url":"https://avatars0.githubusercontent.com/u/3417221?v=4","gravatar_id":"","url":"https://api.github.com/users/nadar","html_url":"https://github.com/nadar","followers_url":"https://api.github.com/users/nadar/followers","following_url":"https://api.github.com/users/nadar/following{/other_user}","gists_url":"https://api.github.com/users/nadar/gists{/gist_id}","starred_url":"https://api.github.com/users/nadar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nadar/subscriptions","organizations_url":"https://api.github.com/users/nadar/orgs","repos_url":"https://api.github.com/users/nadar/repos","events_url":"https://api.github.com/users/nadar/events{/privacy}","received_events_url":"https://api.github.com/users/nadar/received_events","type":"User","site_admin":false},"labels":[{"id":92646963,"url":"https://api.github.com/repos/yiisoft/yii2/labels/severity:important","name":"severity:important","color":"eb6420","default":false},{"id":33208443,"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:bug","name":"type:bug","color":"e102d8","default":false}],"state":"closed","locked":false,"assignee":{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars2.githubusercontent.com/u/4499203?v=4","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false},"assignees":[{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars2.githubusercontent.com/u/4499203?v=4","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/24","html_url":"https://github.com/yiisoft/yii2/milestone/24","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/24/labels","id":2292847,"number":24,"title":"2.0.14","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars0.githubusercontent.com/u/189796?v=4","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":325,"state":"open","created_at":"2017-02-01T16:52:26Z","updated_at":"2018-02-16T21:46:35Z","due_on":"2018-02-10T08:00:00Z","closed_at":null},"comments":3,"created_at":"2018-02-16T13:24:34Z","updated_at":"2018-02-16T21:47:11Z","closed_at":"2018-02-16T21:46:35Z","author_association":"CONTRIBUTOR","body":"### What steps will reproduce the problem?\r\n\r\nJoin a relation and override the default where condition from the relation.\r\n\r\n```php\r\nNavItem::find()\r\n->select(['cms_nav_item.title', 'timestamp_update', 'update_user_id', 'nav_id'])\r\n->joinWith(['updateUser' => function ($q) {\r\n    $q->select(['firstname', 'lastname', 'id'])->where([]);\r\n}, 'nav'])\r\n->where(['cms_nav.is_deleted' => false])\r\n->limit(10)\r\n->orderBy(['timestamp_update' => SORT_DESC])\r\n->asArray(true)\r\n->all();\r\n```\r\n\r\nThe relation inside the model:\r\n\r\n```php\r\npublic function getUpdateUser()\r\n{\r\n    return $this->hasOne(User::class, ['id' => 'update_user_id']);\r\n}\r\n```\r\nThe find method from the User model:\r\n\r\n```php\r\npublic static function find()\r\n{\r\n    return parent::find()->where(['is_deleted' => false]);\r\n}\r\n```\r\n\r\nSo the `$q->select(['firstname', 'lastname', 'id'])->where([]);` will override `where(['is_deleted' => false]);`.\r\n\r\nbtw: I'm sure there is also a better solution for this problem, but it was working in 2.0.13 so i thought it makes sense to report.\r\n\r\n### What is the expected result?\r\n\r\nReturns the array with results.\r\n\r\n### What do you get instead?\r\n\r\nIn the current dev-master the `$q->select(['firstname', 'lastname', 'id'])->where([]);` does not override the relation where condition anymore. this will raise an exception:\r\n\r\n```php\r\n\"SQLSTATE[42000]: Syntax error or access violation: 1064\r\nYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND (`id` IN ('1', '0'))' at line 1\r\nThe SQL being executed was: \r\nSELECT `firstname`, `lastname`, `id`\r\nFROM `admin_user`\r\nWHERE (()) AND (`id` IN ('1', '0'))\"\r\n```\r\n\r\n### Additional info\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      | dev-master\r\n| PHP version      | \r\n| Operating system |\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/366367557","html_url":"https://github.com/yiisoft/yii2/issues/15653#issuecomment-366367557","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/15653","id":366367557,"user":{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars2.githubusercontent.com/u/4499203?v=4","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false},"created_at":"2018-02-16T21:47:11Z","updated_at":"2018-02-16T21:47:11Z","author_association":"MEMBER","body":"Fixed, thank you for the report."}}
{"actor":{"display_login":"SilverFire"}}