{"action":"created","issue":{"url":"https://api.github.com/repos/yajra/laravel-oci8/issues/211","repository_url":"https://api.github.com/repos/yajra/laravel-oci8","labels_url":"https://api.github.com/repos/yajra/laravel-oci8/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-oci8/issues/211/comments","events_url":"https://api.github.com/repos/yajra/laravel-oci8/issues/211/events","html_url":"https://github.com/yajra/laravel-oci8/issues/211","id":180890261,"number":211,"title":"Error in table alias keyword","user":{"login":"fsblemos","id":14933454,"avatar_url":"https://avatars.githubusercontent.com/u/14933454?v=3","gravatar_id":"","url":"https://api.github.com/users/fsblemos","html_url":"https://github.com/fsblemos","followers_url":"https://api.github.com/users/fsblemos/followers","following_url":"https://api.github.com/users/fsblemos/following{/other_user}","gists_url":"https://api.github.com/users/fsblemos/gists{/gist_id}","starred_url":"https://api.github.com/users/fsblemos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsblemos/subscriptions","organizations_url":"https://api.github.com/users/fsblemos/orgs","repos_url":"https://api.github.com/users/fsblemos/repos","events_url":"https://api.github.com/users/fsblemos/events{/privacy}","received_events_url":"https://api.github.com/users/fsblemos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yajra/laravel-oci8/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-04T13:17:42Z","updated_at":"2016-10-07T02:26:40Z","closed_at":null,"body":"### Summary of problem or feature request\r\n\r\nError when generating SQL for self relationships.\r\n\r\n### Code snippet of problem\r\n\r\nI have a model \"Vendedor\" which has a belongsTo self relationship called \"superior\":\r\n\r\n```php\r\nclass Vendedor extends Model\r\n{\r\n    public function superior() {\r\n        return $this->belongsTo(self::class, 'vendedor_id');\r\n    }\r\n}\r\n``` \r\n\r\nWhen I run ```App\\Vendedor::has('superior')->get()```, it generates the following SQL:\r\n\r\n```sql\r\n  select * \r\n    from vendedor \r\n   where exists (select * \r\n                   from vendedor as laravel_reserved_0 \r\n                  where laravel_reserved_0.vendedor_id = vendedor.id)\r\n```\r\n\r\nHowever, the keyword \"as\" is used only in column alias, not in table alias (see [here](https://www.techonthenet.com/oracle/alias.php)). \r\n\r\nThe generated error:\r\n![image](https://cloud.githubusercontent.com/assets/14933454/19075491/7cb4c184-8a1b-11e6-8e4b-ea5c556c5404.png)\r\n\r\n### System details\r\n- Operating System: Windows 7\r\n- PHP Version: 7.0\r\n- Laravel Version: 5.2\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yajra/laravel-oci8/issues/comments/252138838","html_url":"https://github.com/yajra/laravel-oci8/issues/211#issuecomment-252138838","issue_url":"https://api.github.com/repos/yajra/laravel-oci8/issues/211","id":252138838,"user":{"login":"yajra","id":2687997,"avatar_url":"https://avatars.githubusercontent.com/u/2687997?v=3","gravatar_id":"","url":"https://api.github.com/users/yajra","html_url":"https://github.com/yajra","followers_url":"https://api.github.com/users/yajra/followers","following_url":"https://api.github.com/users/yajra/following{/other_user}","gists_url":"https://api.github.com/users/yajra/gists{/gist_id}","starred_url":"https://api.github.com/users/yajra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yajra/subscriptions","organizations_url":"https://api.github.com/users/yajra/orgs","repos_url":"https://api.github.com/users/yajra/repos","events_url":"https://api.github.com/users/yajra/events{/privacy}","received_events_url":"https://api.github.com/users/yajra/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T02:26:40Z","updated_at":"2016-10-07T02:26:40Z","body":"@fsblemos that `as` keyword is one of the reasons why I created several packages and maintain another fork of some packages for them to work on Oracle. I was first hesitant to submit a PR to the community packages as it was only for Oracle and Laravel does not officially support it. However, after all the packages I went through, I just realized that it works on other databases too so I guess it is safer to remove `as` for broader compatibility. I think I also made some several attempts to submit a PR on other packages but was closed due to the fact that Oracle is not officially supported by Laravel.\r\n\r\nA better example is my [datatables](https://github.com/yajra/laravel-datatables) package. It started as a fork of [Bllim](https://github.com/bllim/laravel4-datatables-package) because it doesn't work on Oracle because of `as` keyword when counting the records."}}
{"actor":{"display_login":"yajra"}}