Closed jberger closed 8 years ago
Not sure what to do here, for now i've just fixed the error in the docs. https://github.com/kraih/mojo-pg/commit/99cccdd7c2a7e659d81fd62fd361735aaaf63385
Ah, so there is a different version of point (1) (which is how you fixed the docs). I didn't think that would work because I didn't think it would let you remove the only schema in your search path.
I think Mojo::Pg
should use attribute search_path
for any new connections in _dequeue
and for any returned connections in _enqueue
methods.
Also might be in Mojo::Pg::Database
add new method search_path
for forced set new search_path for connection?
It's been two weeks, and i'm afraid i don't see this issue going anywhere.
So you think, that it's normal behavior when a db
method can return connections with a schemes different from the search_path
attribute?
Steps to reproduce the behavior
When following the example of using search_path to implement isolation (seen here http://mojolicious.org/perldoc/Mojo/Pg#search_path) I ran into the problem of the search path not being set correctly for the connection that was already used to create the schema. I first demonstrated the problem via this test (when I realized that replacing the Mojo::Pg object would "fix" the problem).
However as I began to realize that this was really about connection caching I realized that the following patten would work reliably and without the confusion. Note the setting of
max_connections
which prevents connection caching until after the schema is created and the search path would go into effect.Expected behavior
The example would be expected to create new objects in the current database schema. I see three possible solutions here.
->max_connections(0)
and later reset to the documentation in that example. It works without any code changes but it isn't very pretty.search_path
is set. This is the least cognitive load on the user but is the most intrusive solution.