{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/8436","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/8436/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/8436/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/8436/events","html_url":"https://github.com/cakephp/cakephp/issues/8436","id":139735906,"number":8436,"title":"3.2.4 complex conditions in addAssociations are ignored","user":{"login":"Graziel","id":5963584,"avatar_url":"https://avatars.githubusercontent.com/u/5963584?v=3","gravatar_id":"","url":"https://api.github.com/users/Graziel","html_url":"https://github.com/Graziel","followers_url":"https://api.github.com/users/Graziel/followers","following_url":"https://api.github.com/users/Graziel/following{/other_user}","gists_url":"https://api.github.com/users/Graziel/gists{/gist_id}","starred_url":"https://api.github.com/users/Graziel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graziel/subscriptions","organizations_url":"https://api.github.com/users/Graziel/orgs","repos_url":"https://api.github.com/users/Graziel/repos","events_url":"https://api.github.com/users/Graziel/events{/privacy}","received_events_url":"https://api.github.com/users/Graziel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/ORM","name":"ORM","color":"ffffff"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/82","html_url":"https://github.com/cakephp/cakephp/milestones/3.2.5","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/82/labels","id":1625052,"number":82,"title":"3.2.5","description":"Bugfixes and minor optimizations for 3.2.x","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":33,"closed_issues":11,"state":"open","created_at":"2016-03-07T01:54:50Z","updated_at":"2016-03-10T02:37:21Z","due_on":"2016-03-20T04:00:00Z","closed_at":null},"comments":1,"created_at":"2016-03-09T23:41:56Z","updated_at":"2016-03-10T02:38:15Z","closed_at":null,"body":"This is a (multiple allowed):\r\n* [x] bug\r\n* [ ] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: 3.2.4\r\n\r\n### What you did\r\ni have belongsToMany association with condition:\r\n```PHP\r\npublic function initialize(array $config)\r\n{\r\n\t$this->addAssociations([\r\n\t\t'belongsToMany' => [\r\n\t\t\t'FriendlyInvites' => [\r\n\t\t\t\t'className' => 'Users',\r\n\t\t\t\t'foreignKey' => 'user_id',\r\n\t\t\t\t'joinTable' => 'users_friends',\r\n\t\t\t\t'conditions' => [\r\n\t\t\t\t\t'OR' => [\r\n\t\t\t\t\t\t['UsersFriends.accepted' => 0],\r\n\t\t\t\t\t\t['UsersFriends.accepted IS' => null]\r\n\t\t\t\t\t]\r\n\t\t\t\t],\r\n\t\t\t\t'saveStrategy' => 'append'\r\n\t\t\t]\r\n\t\t]\r\n\t]);\r\n}\r\n```\r\n\r\n### Expected Behavior\r\n```SQL\r\nFROM \r\n  users FriendlyInvites \r\n  INNER JOIN users_friends UsersFriends ON FriendlyInvites.id = (UsersFriends.user_id) \r\nWHERE \r\n  UsersFriends.user_id in (159) \r\n    AND (UsersFriends.accepted = 0 OR UsersFriends.accepted IS NULL)\r\n```\r\nquery with conditions\r\n\r\n### Actual Behavior\r\n```SQL\r\nFROM \r\n  users FriendlyInvites \r\n  INNER JOIN users_friends UsersFriends ON FriendlyInvites.id = (UsersFriends.user_id) \r\nWHERE \r\n  UsersFriends.user_id in ('159')\r\n```\r\nthe condition is being ignored"},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/194629419","html_url":"https://github.com/cakephp/cakephp/issues/8436#issuecomment-194629419","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/8436","id":194629419,"user":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T02:38:14Z","updated_at":"2016-03-10T02:38:14Z","body":"How are you creating the above query?"}}