File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl SqlxPostgresConnector {
7979 let set_search_path_sql = options
8080 . schema_search_path
8181 . as_ref ( )
82- . map ( |schema| format ! ( "SET search_path = {schema}" ) ) ;
82+ . map ( |schema| format ! ( "SET search_path = \" {schema}\" " ) ) ;
8383 let lazy = options. connect_lazy ;
8484 let mut pool_options = options. sqlx_pool_options ( ) ;
8585 if let Some ( sql) = set_search_path_sql {
Original file line number Diff line number Diff line change @@ -140,3 +140,23 @@ pub async fn connection_ping_closed_postgres() {
140140
141141 ctx. delete ( ) . await ;
142142}
143+
144+ #[ sea_orm_macros:: test]
145+ #[ cfg( feature = "sqlx-postgres" ) ]
146+ pub async fn connection_with_search_path_postgres ( ) {
147+ let ctx = TestContext :: new ( "connection_with_search_path" ) . await ;
148+
149+ let base_url = std:: env:: var ( "DATABASE_URL" ) . unwrap ( ) ;
150+ let mut opt = sea_orm:: ConnectOptions :: new ( format ! ( "{base_url}/connection_with_search_path" ) ) ;
151+ opt
152+ // The connection pool has a single connection only
153+ . max_connections ( 1 )
154+ // A controlled connection acquire timeout
155+ . acquire_timeout ( std:: time:: Duration :: from_secs ( 2 ) )
156+ . set_schema_search_path ( "schema-with-special-characters" ) ;
157+
158+ let db = sea_orm:: Database :: connect ( opt) . await ;
159+ assert ! ( db. is_ok( ) ) ;
160+
161+ ctx. delete ( ) . await ;
162+ }
You can’t perform that action at this time.
0 commit comments