Put schema in quotes for postgres driver (#2436)
* Put schema in quotes for postgres driver * Add tests
This commit is contained in:
parent
8a256cec6a
commit
e27e1d9657
@ -79,7 +79,7 @@ impl SqlxPostgresConnector {
|
|||||||
let set_search_path_sql = options
|
let set_search_path_sql = options
|
||||||
.schema_search_path
|
.schema_search_path
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|schema| format!("SET search_path = {schema}"));
|
.map(|schema| format!("SET search_path = \"{schema}\""));
|
||||||
let lazy = options.connect_lazy;
|
let lazy = options.connect_lazy;
|
||||||
let mut pool_options = options.sqlx_pool_options();
|
let mut pool_options = options.sqlx_pool_options();
|
||||||
if let Some(sql) = set_search_path_sql {
|
if let Some(sql) = set_search_path_sql {
|
||||||
|
@ -140,3 +140,23 @@ pub async fn connection_ping_closed_postgres() {
|
|||||||
|
|
||||||
ctx.delete().await;
|
ctx.delete().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[sea_orm_macros::test]
|
||||||
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
|
pub async fn connection_with_search_path_postgres() {
|
||||||
|
let ctx = TestContext::new("connection_with_search_path").await;
|
||||||
|
|
||||||
|
let base_url = std::env::var("DATABASE_URL").unwrap();
|
||||||
|
let mut opt = sea_orm::ConnectOptions::new(format!("{base_url}/connection_with_search_path"));
|
||||||
|
opt
|
||||||
|
// The connection pool has a single connection only
|
||||||
|
.max_connections(1)
|
||||||
|
// A controlled connection acquire timeout
|
||||||
|
.acquire_timeout(std::time::Duration::from_secs(2))
|
||||||
|
.set_schema_search_path("schema-with-special-characters");
|
||||||
|
|
||||||
|
let db = sea_orm::Database::connect(opt).await;
|
||||||
|
assert!(db.is_ok());
|
||||||
|
|
||||||
|
ctx.delete().await;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user