{"action":"created","issue":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/2298","repository_url":"https://api.github.com/repos/typeorm/typeorm","labels_url":"https://api.github.com/repos/typeorm/typeorm/issues/2298/labels{/name}","comments_url":"https://api.github.com/repos/typeorm/typeorm/issues/2298/comments","events_url":"https://api.github.com/repos/typeorm/typeorm/issues/2298/events","html_url":"https://github.com/typeorm/typeorm/issues/2298","id":330137119,"node_id":"MDU6SXNzdWUzMzAxMzcxMTk=","number":2298,"title":"Repository filtering not considering related columns as filter","user":{"login":"Sturgelose","id":244191,"node_id":"MDQ6VXNlcjI0NDE5MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/244191?v=4","gravatar_id":"","url":"https://api.github.com/users/Sturgelose","html_url":"https://github.com/Sturgelose","followers_url":"https://api.github.com/users/Sturgelose/followers","following_url":"https://api.github.com/users/Sturgelose/following{/other_user}","gists_url":"https://api.github.com/users/Sturgelose/gists{/gist_id}","starred_url":"https://api.github.com/users/Sturgelose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sturgelose/subscriptions","organizations_url":"https://api.github.com/users/Sturgelose/orgs","repos_url":"https://api.github.com/users/Sturgelose/repos","events_url":"https://api.github.com/users/Sturgelose/events{/privacy}","received_events_url":"https://api.github.com/users/Sturgelose/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-07T06:43:08Z","updated_at":"2018-06-07T06:55:57Z","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[X] `mysql` / `mariadb`\r\n[ ] `oracle`\r\n[ ] `postgres`\r\n[ ] `sqlite`\r\n[ ] `sqljs`\r\n[ ] `react-native`\r\n\r\n**TypeORM version:**\r\n\r\n[X] `latest`  (0.2.7)\r\n[X] `@next` (0.3.0-alpha.5)\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\nCreate models with multiple levels of relations:\r\n```\r\n@Entity()\r\nclass Ticket {\r\n@PrimaryGeneratedColumn() id: number;\r\n@Column() shopId: string;\r\n@Column() chainId: string;\r\n@OneToMany(type => TicketProduct, ticketProduct => ticketProduct.ticket)\r\n  ticketItems: TicketProduct[];\r\n}\r\n\r\n@Entity()\r\nclass TicketProduct {\r\n@PrimaryGeneratedColumn() id: number;\r\n@ManyToOne(type => Product, product => product.id)\r\n product: Product;\r\n@ManyToOne(type => Ticket, ticket => ticket.id)\r\nticket: Ticket;\r\n}\r\n\r\n@Entity()\r\nclass Product {\r\n@PrimaryGeneratedColumn() id: number;\r\n@OneToMany(type => TicketProduct, ticketp => ticketp.product)\r\nticketProduct: TicketProduct[];\r\n}\r\n```\r\n\r\nI'm trying to do a query from the Ticket repository, adding TicketProduct and Product as related (which works up to here), but when I try to filter by Product ID, this doesn't appear reflected in the query.\r\n\r\nMy query is one such as:\r\n```\r\nlet query = {\r\n  where: {\r\n     shopId: 'myshopId',\r\n     chainId: 'myChainId',\r\n     ticketItems = {\r\n        product: {\r\n          id: In(['id1', 'id2', 'id3']), // This gets ignored and not included in the query!\r\n        },\r\n      },\r\n    },\r\n  relations: ['ticketItems', 'ticketItems.product'],\r\n}\r\nthis.ticketRepository.find(query);\r\n```\r\n\r\nResult query (SELECT a bit stripped off as it's a bit long):\r\n```\r\nSELECT * \r\nFROM `ticket` `Ticket` \r\nLEFT JOIN `ticket_product` `Ticket_ticketItems` ON `Ticket_ticketItems`.`ticketId`=`Ticket`.`id`  LEFT JOIN `product` `Ticket_ticketItems_product` ON `Ticket_ticketItems_product`.`id`=`Ticket_ticketItems`.`productId` \r\nWHERE `Ticket`.`shopId` = ? AND `Ticket`.`chainId` = ?\r\n\r\n```\r\nAs you see there is no AND `Ticket_ticketItems_product`.`id` IN [id1, id2, id3]\r\n"},"comment":{"url":"https://api.github.com/repos/typeorm/typeorm/issues/comments/395313619","html_url":"https://github.com/typeorm/typeorm/issues/2298#issuecomment-395313619","issue_url":"https://api.github.com/repos/typeorm/typeorm/issues/2298","id":395313619,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTMxMzYxOQ==","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-07T06:55:57Z","updated_at":"2018-06-07T06:55:57Z","author_association":"MEMBER","body":"I was talking about query part. For example `ticketItems = {` is not valid, it shall be `ticketItems: {`. Also `relations: ['ticketItems', 'ticketItems.product']` should give you compiler error since last part definitely won't work in `@next`"}}
{"actor":{"display_login":"pleerock"}}