{"action":"created","issue":{"url":"https://api.github.com/repos/auraphp/Aura.SqlQuery/issues/38","labels_url":"https://api.github.com/repos/auraphp/Aura.SqlQuery/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/auraphp/Aura.SqlQuery/issues/38/comments","events_url":"https://api.github.com/repos/auraphp/Aura.SqlQuery/issues/38/events","html_url":"https://github.com/auraphp/Aura.SqlQuery/issues/38","id":40640916,"number":38,"title":"Should Queries Keep Track of Joined Tables?","user":{"login":"chrisguitarguy","id":1010392,"avatar_url":"https://avatars.githubusercontent.com/u/1010392?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisguitarguy","html_url":"https://github.com/chrisguitarguy","followers_url":"https://api.github.com/users/chrisguitarguy/followers","following_url":"https://api.github.com/users/chrisguitarguy/following{/other_user}","gists_url":"https://api.github.com/users/chrisguitarguy/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisguitarguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisguitarguy/subscriptions","organizations_url":"https://api.github.com/users/chrisguitarguy/orgs","repos_url":"https://api.github.com/users/chrisguitarguy/repos","events_url":"https://api.github.com/users/chrisguitarguy/events{/privacy}","received_events_url":"https://api.github.com/users/chrisguitarguy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-08-19T21:49:37Z","updated_at":"2015-03-04T22:26:38Z","closed_at":null,"body":"I'm building an application that uses a lot of other objects to modify an Aura query builder object.\r\n\r\nOne issue I ran into is that the query builders don't keep track of joined tables. So something like this:\r\n\r\n```php\r\nuse Aura\\SqlQuery\\QueryFactory;\r\n\r\n$factory = new QueryFactory('mysql');\r\n\r\n$select = $factory->newSelect();\r\n\r\n$select->cols([\r\n    'SUM(clicks)' => 'clicks',\r\n]);\r\n$select->from('some_table');\r\n$select->join('other', 'some_table.id = other.id');\r\n\r\n// some other object does it again\r\n$select->join('other', 'some_table.id = other.id');\r\n\r\necho $select, PHP_EOL;\r\n```\r\n\r\nI would expect the join to only be generated a single time, but that's not the case:\r\n\r\n```sql\r\nSELECT\r\n    SUM(clicks) AS `clicks`\r\nFROM\r\n    `some_table`\r\nOTHER JOIN `some_table`.`id` `=` `other.id`\r\nOTHER JOIN `some_table`.`id` `=` `other.id`\r\n```\r\n\r\nIt's easy enough to solve with client code, but it seems like it might be a nice feature for the query builders in general."},"comment":{"url":"https://api.github.com/repos/auraphp/Aura.SqlQuery/issues/comments/77263865","html_url":"https://github.com/auraphp/Aura.SqlQuery/issues/38#issuecomment-77263865","issue_url":"https://api.github.com/repos/auraphp/Aura.SqlQuery/issues/38","id":77263865,"user":{"login":"pmjones","id":25754,"avatar_url":"https://avatars.githubusercontent.com/u/25754?v=3","gravatar_id":"","url":"https://api.github.com/users/pmjones","html_url":"https://github.com/pmjones","followers_url":"https://api.github.com/users/pmjones/followers","following_url":"https://api.github.com/users/pmjones/following{/other_user}","gists_url":"https://api.github.com/users/pmjones/gists{/gist_id}","starred_url":"https://api.github.com/users/pmjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmjones/subscriptions","organizations_url":"https://api.github.com/users/pmjones/orgs","repos_url":"https://api.github.com/users/pmjones/repos","events_url":"https://api.github.com/users/pmjones/events{/privacy}","received_events_url":"https://api.github.com/users/pmjones/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T22:26:38Z","updated_at":"2015-03-04T22:26:38Z","body":"I'm trying to elicit what would be a satisfactory set of conditions. Perhaps submitting a PR would be best at this point."}}