mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.26k stars 217 forks source link

PHPUnit SQLite Multiple connections, missmatch cache key #272

Closed anderson-comvex closed 5 years ago

anderson-comvex commented 5 years ago

Describe the bug

While running integration and feature tests using SQLite driver and the query is not completed initialized in a multitenant scenario and for example the value of $this->query->toSql() will be select * or 1, this will fallback to the default connection instead of using the proper model connection.

Eloquent Query

src/Traits/CachePrefixing.php
$this->model->getConnection()->getDatabaseName()

Environment

Additional context Since the query is not complete or valid in the target table, eloquent falls back to the default connection, which on the model constructor the defined connection is different, using a multitenant with multiple connections.