{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/3903","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/3903/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/3903/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/3903/events","html_url":"https://github.com/sequelize/sequelize/issues/3903","id":86573411,"number":3903,"title":"Turn of prefix in where clause, nested where, include where parent","user":{"login":"Orvacko","id":1727586,"avatar_url":"https://avatars.githubusercontent.com/u/1727586?v=3","gravatar_id":"","url":"https://api.github.com/users/Orvacko","html_url":"https://github.com/Orvacko","followers_url":"https://api.github.com/users/Orvacko/followers","following_url":"https://api.github.com/users/Orvacko/following{/other_user}","gists_url":"https://api.github.com/users/Orvacko/gists{/gist_id}","starred_url":"https://api.github.com/users/Orvacko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Orvacko/subscriptions","organizations_url":"https://api.github.com/users/Orvacko/orgs","repos_url":"https://api.github.com/users/Orvacko/repos","events_url":"https://api.github.com/users/Orvacko/events{/privacy}","received_events_url":"https://api.github.com/users/Orvacko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-09T12:02:54Z","updated_at":"2015-06-09T12:23:56Z","closed_at":null,"body":"Hi,\r\n\r\nis there any posibility to turn of 'table_prefix' in where clause?\r\n\r\nProblem:\r\n```js\r\n...\r\nfinder.include = {model: db.Company, attributes: ['id', 'name'], as: 'payer', where: where2};\r\nfinder.where = db.Sequelize.and(where, {company_company_id: req.query.company_id});\r\ndb.CompanyPayers.findAndCountAll(finder).then(function(result) {\r\n...\r\n```\r\nOutput:\r\n```sql\r\nSELECT count(`company_payers`.`id`) AS `count`\r\nFROM `acrm_company_payers` AS `company_payers`\r\nINNER JOIN `acrm_companies` AS `payer` ON `company_payers`.`payer_id` = `payer`.`company_id`\r\nAND (`payer`.`deleted` IS NULL\r\n     AND `payer`.`name` LIKE '%ab%')\r\nWHERE (`company_payers`.`deleted` IS NULL\r\n       AND ((`company_payers`.`id` LIKE '%ab%'\r\n             OR `company_payers`.`created_by` LIKE '%ab%'\r\n             OR `company_payers`.`created` LIKE '%ab%')\r\n            AND `company_payers`.`company_company_id` = '134837'));\r\n```\r\n\r\nIs there any posibility to aim this? (different is bold):\r\n\r\n SELECT count(`company_payers`.`id`) AS `count` FROM `acrm_company_payers` AS `company_payers` INNER JOIN `acrm_companies` AS `payer` ON `company_payers`.`payer_id` = `payer`.`company_id` AND (`payer`.`deleted` IS NULL AND `payer`.`name` LIKE '%ab%') WHERE (`company_payers`.`deleted` IS NULL AND ((`company_payers`.`id` LIKE '%ab%' OR `company_payers`.`created_by` LIKE '%ab%' OR `company_payers`.`created` LIKE '%ab%' __OR `payer`.name LIKE '%ab%'__) AND `company_payers`.`company_company_id` = '134837'));\r\n\r\nWhen you use:\r\n```\r\n...\r\nwhere.name = {$like: '%ab%'};\r\nfinder.include = {model: db.Company, attributes: ['id', 'name'], as: 'payer', where: where2};\r\nfinder.where = db.Sequelize.and(where, {company_company_id: req.query.company_id});\r\ndb.CompanyPayers.findAndCountAll(finder).then(function(result) {\r\n...\r\n```\r\n\r\nThat where will add `company_payers` prefix so output is this: (different is bold)\r\nSELECT count(`company_payers`.`id`) AS `count` FROM `acrm_company_payers` AS `company_payers` INNER JOIN `acrm_companies` AS `payer` ON `company_payers`.`payer_id` = `payer`.`company_id` AND (`payer`.`deleted` IS NULL AND `payer`.`name` LIKE '%ab%') WHERE (`company_payers`.`deleted` IS NULL AND ((`company_payers`.`id` LIKE '%ab%' OR `company_payers`.`created_by` LIKE '%ab%' OR `company_payers`.`created` LIKE '%ab%' __OR `company_payers`.name LIKE '%ab%'__) AND `company_payers`.`company_company_id` = '134837'));\r\n\r\nI have tried everything, nested where (ex.: where.payer = {name: {$like: '%ab%'}}) but it still generate `company_payers`.payer LIKE [Object ..] and throws error\r\n\r\nThank you"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/110338380","html_url":"https://github.com/sequelize/sequelize/issues/3903#issuecomment-110338380","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/3903","id":110338380,"user":{"login":"janmeier","id":1210224,"avatar_url":"https://avatars.githubusercontent.com/u/1210224?v=3","gravatar_id":"","url":"https://api.github.com/users/janmeier","html_url":"https://github.com/janmeier","followers_url":"https://api.github.com/users/janmeier/followers","following_url":"https://api.github.com/users/janmeier/following{/other_user}","gists_url":"https://api.github.com/users/janmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/janmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janmeier/subscriptions","organizations_url":"https://api.github.com/users/janmeier/orgs","repos_url":"https://api.github.com/users/janmeier/repos","events_url":"https://api.github.com/users/janmeier/events{/privacy}","received_events_url":"https://api.github.com/users/janmeier/received_events","type":"User","site_admin":false},"created_at":"2015-06-09T12:23:56Z","updated_at":"2015-06-09T12:23:56Z","body":"No, it is not possible to turn of the prefix. But it should still be possible to do what you want.\r\n\r\nCan you show model definitions and assoications?"}}