Describe the bug
Like #958 the QueryBuilder class creates a new connection object for many calls to the backend.
Ideally the new_connection() method should only return (not store) the connection object and the get_connection() method should be used to manage the internal _commection instance var.
To Reproduce
see this code:
def new_connection(self):
if self._connection:
return self._connection
self._connection = (
self.connection_class(
**self.get_connection_information(), name=self.connection
)
.set_schema(self._schema)
.make_connection()
)
return self._connection
def get_connection(self):
return self._connection
Expected behavior
get_connection() should be used internally (possibly elsewhere as well)
so connections are not made to the backend unneccarily.
Screenshots or code snippets
N/A
Desktop (please complete the following information):
- OS: MacOS
- Version 12.7 Monterey
What database are you using?
- Type: Postgres, MySQL, SQLite
- Version any
- Masonite ORM: latest 2.0 and latest 3.0 (latest 3.x branch)
Additional context
None
Describe the bug
Like #958 the QueryBuilder class creates a new connection object for many calls to the backend.
Ideally the
new_connection()method should only return (not store) the connection object and theget_connection()method should be used to manage the internal_commectioninstance var.To Reproduce
see this code:
Expected behavior
get_connection()should be used internally (possibly elsewhere as well)so connections are not made to the backend unneccarily.
Screenshots or code snippets
N/A
Desktop (please complete the following information):
What database are you using?
Additional context
None