-
-
Notifications
You must be signed in to change notification settings - Fork 53
QueryBuilder should use get_connection() not new_connection() internally #960
Copy link
Copy link
Open
Labels
bugAn existing feature is not working as intendedAn existing feature is not working as intended
Description
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._connectionExpected 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugAn existing feature is not working as intendedAn existing feature is not working as intended