{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/25133","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/25133/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/25133/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/25133/events","html_url":"https://github.com/laravel/framework/issues/25133","id":348444173,"node_id":"MDU6SXNzdWUzNDg0NDQxNzM=","number":25133,"title":"SqlServer Database connection driver selection","user":{"login":"paierlep","id":1857463,"node_id":"MDQ6VXNlcjE4NTc0NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1857463?v=4","gravatar_id":"","url":"https://api.github.com/users/paierlep","html_url":"https://github.com/paierlep","followers_url":"https://api.github.com/users/paierlep/followers","following_url":"https://api.github.com/users/paierlep/following{/other_user}","gists_url":"https://api.github.com/users/paierlep/gists{/gist_id}","starred_url":"https://api.github.com/users/paierlep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paierlep/subscriptions","organizations_url":"https://api.github.com/users/paierlep/orgs","repos_url":"https://api.github.com/users/paierlep/repos","events_url":"https://api.github.com/users/paierlep/events{/privacy}","received_events_url":"https://api.github.com/users/paierlep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-08-07T18:50:57Z","updated_at":"2018-08-09T06:55:29Z","closed_at":null,"author_association":"NONE","body":"- Laravel Version: 5.5.x\r\n- PHP Version: 7.1\r\n- Database Driver & Version: SqlServer with sqlsrv *and* dblib driver\r\n\r\n### Description:\r\nThe server had - for whatever reason - both dblib and sqlsrv driver installed. First one (dblib) with some error so connection was not possible. This is the database section of the env file similarily to the used one:\r\n \r\n```\r\nDB_CONNECTION=sqlsrv\r\nDB_HOST= 10.0.0.5\r\nDB_PORT=1433\r\nDB_DATABASE=testdb\r\nDB_USERNAME=testuser\r\nDB_PASSWORD=testpassword\r\n```\r\n\r\nLaravel recognized the existence of dblib and ignored the driver value of the database configuration (where sqlsrv was selected), and took the dblib driver together with a very cryptic error message when using the mssql database (this however could have been due to the malfunctioning driver):\r\n\r\n```\r\nPDOException : SQLSTATE[HY001] Unable to allocate sufficient memory (10.0.5.87:1433) (severity 8)\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:43\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php:32\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:183\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1719\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1704\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:483\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:467\r\n/srv/www/vhosts/ds/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:77\r\n[...]\r\n```\r\nI would have expected that:\r\n- sqlsrv is used instead of dblib, because it is explicitly set in the .env file\r\n\r\nAs far as I have seen in [SqlServerConnector.php#L41](https://github.com/laravel/framework/blob/240d904606a101f5104bff8a1d09678c44f11903/src/Illuminate/Database/Connector /SqlServerConnector.php#L41) the available modules are fetched and then always used in the same order (if present): dblib, odbc and then sqlsrv. \r\n\r\nI suggest to take the user's database configuration into account here, or at least switch the order to prefer sqlsrv as dblib has died with php 5.3 (http://php.net/manual/en/ref.pdo-dblib.php)\r\n\r\nIf you want I can provide an pull request fixing that."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/411656591","html_url":"https://github.com/laravel/framework/issues/25133#issuecomment-411656591","issue_url":"https://api.github.com/repos/laravel/framework/issues/25133","id":411656591,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMTY1NjU5MQ==","user":{"login":"paierlep","id":1857463,"node_id":"MDQ6VXNlcjE4NTc0NjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1857463?v=4","gravatar_id":"","url":"https://api.github.com/users/paierlep","html_url":"https://github.com/paierlep","followers_url":"https://api.github.com/users/paierlep/followers","following_url":"https://api.github.com/users/paierlep/following{/other_user}","gists_url":"https://api.github.com/users/paierlep/gists{/gist_id}","starred_url":"https://api.github.com/users/paierlep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paierlep/subscriptions","organizations_url":"https://api.github.com/users/paierlep/orgs","repos_url":"https://api.github.com/users/paierlep/repos","events_url":"https://api.github.com/users/paierlep/events{/privacy}","received_events_url":"https://api.github.com/users/paierlep/received_events","type":"User","site_admin":false},"created_at":"2018-08-09T06:55:29Z","updated_at":"2018-08-09T06:55:29Z","author_association":"NONE","body":"@X-Coder264 Thank you for looking into the issue - I completely overlooked the ConnectionFactory. I believe that Laravel could (and should) be more transparent here and pass that value to the SqlServerConnector, at least it was really confusing when debugging my underlying issue.\r\n\r\nHowever this is a very minor problem as:\r\na.) (for now) only MSSQL Server has more than one PDO driver\r\nb.) one of the two is deprecated\r\nc.) it is possible to detect any faulty driver and handling that should be done within the php/server configuration itself\r\n\r\nSo although i wish for said change (as it would help users today), i do believe that the current solution is fine (no legacy code in the future) - and you could close the issue ;)"}}
{"actor":{"display_login":"paierlep"}}