{"action":"created","issue":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/2287","repository_url":"https://api.github.com/repos/typeorm/typeorm","labels_url":"https://api.github.com/repos/typeorm/typeorm/issues/2287/labels{/name}","comments_url":"https://api.github.com/repos/typeorm/typeorm/issues/2287/comments","events_url":"https://api.github.com/repos/typeorm/typeorm/issues/2287/events","html_url":"https://github.com/typeorm/typeorm/issues/2287","id":329687850,"node_id":"MDU6SXNzdWUzMjk2ODc4NTA=","number":2287,"title":"QueryBuilder IN and ANY Fail with .where - Postgres","user":{"login":"svstartuplab","id":5234493,"node_id":"MDQ6VXNlcjUyMzQ0OTM=","avatar_url":"https://avatars0.githubusercontent.com/u/5234493?v=4","gravatar_id":"","url":"https://api.github.com/users/svstartuplab","html_url":"https://github.com/svstartuplab","followers_url":"https://api.github.com/users/svstartuplab/followers","following_url":"https://api.github.com/users/svstartuplab/following{/other_user}","gists_url":"https://api.github.com/users/svstartuplab/gists{/gist_id}","starred_url":"https://api.github.com/users/svstartuplab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svstartuplab/subscriptions","organizations_url":"https://api.github.com/users/svstartuplab/orgs","repos_url":"https://api.github.com/users/svstartuplab/repos","events_url":"https://api.github.com/users/svstartuplab/events{/privacy}","received_events_url":"https://api.github.com/users/svstartuplab/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-06T02:25:44Z","updated_at":"2018-06-07T15:38:14Z","closed_at":null,"author_association":"NONE","body":"**Issue type:**\r\n\r\n[ ] question\r\n[x ] bug report\r\n[ ] feature request\r\n[ ] documentation issue\r\n\r\n**Database system/driver:**\r\n\r\n[ ] `cordova`\r\n[ ] `mongodb`\r\n[ ] `mssql`\r\n[ ] `mysql` / `mariadb`\r\n[ ] `oracle`\r\n[ x] `postgres`\r\n[ ] `sqlite`\r\n[ ] `sqljs`\r\n[ ] `react-native`\r\n\r\n**TypeORM version:**\r\n\r\n[x ] `latest`\r\n[ ] `@next`\r\n[ ] `0.x.x` (or put your version here)\r\n\r\n**Steps to reproduce or a small repository showing the problem:**\r\n\r\nThis works:\r\n\r\n```\r\n    const sql = 'SELECT * FROM members WHERE '+ integerId + ' = ANY(skill_id_array)';\r\n    const membersBySkill = await this.entityManager.query(sql);\r\n    // This works: SELECT * FROM members WHERE 2 = ANY(skill_id_array)\r\n```\r\n\r\nEdit:  Also this works, although not originally because I set it up like the 'Any' example in Find Options in the docs.  This needs to be added to the QB doc for those of us who are new to the whole server stack and learning from the docs.\r\n\r\n```\r\nconst membersBySkill = await getRepository(Members)\r\n      .createQueryBuilder()\r\n      .where(':id = ANY (skill_id_array)', {id: integerId})\r\n      .getMany();\r\n```\r\n\r\nI've tried many setups but the two in the comments below have typical errors.  The problem seems to be in the .where with both IN and ANY.  Select statements are from my console.log on the server.  The var integerId as a value of say 2, is an integer and skill_id_array is a column in the db with values such as {1,2,5}.  There are no examples of my use in the docs or elsewhere and I suspect that this setup doesn't work in TypeORM yet or is a bug.\r\n\r\n```\r\n   const membersBySkill = await getRepository(Members)\r\n      .createQueryBuilder()\r\n      // .select('*') Do not use here. QB needs the entire selection per @pleerock in comments below.\r\n      .where(':id IN (skill_id_array)', {id: integerId})\r\n      .getMany();\r\n   console.log('membersBySkill: ', membersBySkill);\r\n   return membersBySkill;\r\n\r\n    //  {id: '{2}'}) -> SELECT * FROM \"members\" \"Members\" WHERE $1 IN (skill_id_array) -- PARAMETERS: [\"{2}\"]\r\n    //  membersBySkill =  [] empty array and no error.\r\n    //  {id: integerId} -> SELECT * FROM \"members\" \"Members\" WHERE $1 IN (skill_id_array) -- PARAMETERS: [2]\r\n    //  errors: malformed array literal: \"2\"  &  Array value must start with \"{\" or dimension information.\r\n```"},"comment":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/comments/395466732","html_url":"https://github.com/typeorm/typeorm/issues/2287#issuecomment-395466732","issue_url":"https://api.github.com/repos/typeorm/typeorm/issues/2287","id":395466732,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTQ2NjczMg==","user":{"login":"pleerock","id":1753397,"node_id":"MDQ6VXNlcjE3NTMzOTc=","avatar_url":"https://avatars3.githubusercontent.com/u/1753397?v=4","gravatar_id":"","url":"https://api.github.com/users/pleerock","html_url":"https://github.com/pleerock","followers_url":"https://api.github.com/users/pleerock/followers","following_url":"https://api.github.com/users/pleerock/following{/other_user}","gists_url":"https://api.github.com/users/pleerock/gists{/gist_id}","starred_url":"https://api.github.com/users/pleerock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pleerock/subscriptions","organizations_url":"https://api.github.com/users/pleerock/orgs","repos_url":"https://api.github.com/users/pleerock/repos","events_url":"https://api.github.com/users/pleerock/events{/privacy}","received_events_url":"https://api.github.com/users/pleerock/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T15:38:13Z","updated_at":"2018-06-07T15:38:13Z","author_association":"MEMBER","body":"> I will contribute $100 on OpenCollective soon. \r\n\r\nThank you! 👍 \r\n\r\n>  I also contribute by asking questions on SO and posting answers when I solve them. It should help others.\r\n\r\nThank you very much, this is very important for TypeORM\r\n\r\nWhat is `skill_id_array` in your code? Can you show your entity?"}}
{"actor":{"display_login":"pleerock"}}