Closed adriangb closed 1 year ago
@euri10 so the reason a connection
was being passed around was to make sure everything ran inside a transaction. Your feedback makes me think the root of the issue is that SupportsBackend
is doing too many things. I think splitting it into two interfaces like this makes it a lot easier to understand what's going on and how it should be used. Now we have 2 interfaces:
SupportsBackend
which is responsible for (1) creating a SupportsBackendExecutor
(i.e. connecting to the db and/or creating a transaction) and (2) creating an executable function from .sql
file.SupportsBackendExecutor
which is responsible for actually executing things and should internally have a connection wrapped in a transaction. Since this connection is now always wrapped in a transaction (or whatever the backend needs) it can use self.connection
instead of having the connection as a parameter to each method, which is what you had originally proposed for SupportsBackend
.I also renamed execute_sql_file
to prepare_operation_from_sql_file
which I think makes it's usage clearer.
How does this sound to you?
this is way cleaner yep !
Closes #4