mpociot / laravel-test-factory-helper

Generate Laravel test factories from your existing models
935 stars 87 forks source link

[Proposal Solution] Exception: SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute Could not analyze class Modules\Pdm\Models\PickingList\PickingListItem #25

Open ijpatricio opened 5 years ago

ijpatricio commented 5 years ago

Hello @mpociot

Hope to find you well!

So, with DBAL, for SQL server, is needed to set some option. Already solver this before. For such connections, to work out of the box, something similar to this will work.

protected function setNeededPdoSettings()
    {
        $connectionsSqlServer = [
            'x3db_v11',
            'roots_sql_server',
            'imos',
        ];

        collect($connectionsSqlServer)
            ->each(function ($item, $key) {
                config()->set("database.connections.{$item}.options",[
                    \PDO::ATTR_PERSISTENT => true
                ]);
            });

    }

It puts that option on the fly, for the current execution. I could rewrite above snipper to apply such setting to every SQL Server connection, and make a PR. What do you think?