mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-28 22:01:33 +00:00
Update utils.rs
This commit is contained in:
parent
1f30b38ca2
commit
87e86825f4
1 changed files with 15 additions and 7 deletions
|
@ -340,12 +340,18 @@ fn establish_connection(config: &str) -> BoxFuture<ConnectionResult<AsyncPgConne
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let mut conn = AsyncPgConnection::try_from(client).await?;
|
let mut conn = AsyncPgConnection::try_from(client).await?;
|
||||||
// * Change geqo_threshold back to default value if it was changed, so it's higher than the
|
diesel::select((
|
||||||
// collapse limits
|
// Change geqo_threshold back to default value if it was changed, so it's higher than the
|
||||||
// * Change collapse limits from 8 to 11 so the query planner can find a better table join order
|
// collapse limits
|
||||||
// for more complicated queries
|
functions::set_config("geqo_threshold", "12", false),
|
||||||
conn
|
// Change collapse limits from 8 to 11 so the query planner can find a better table join order
|
||||||
.batch_execute("SET geqo_threshold=12;SET from_collapse_limit=11;SET join_collapse_limit=11;")
|
// for more complicated queries
|
||||||
|
functions::set_config("from_collapse_limit", "11", false),
|
||||||
|
functions::set_config("join_collapse_limit", "11", false),
|
||||||
|
// * Set `lemmy.protocol_and_hostname` so triggers can use it
|
||||||
|
functions::set_config("lemmy.protocol_and_hostname", SETTINGS.get_protocol_and_hostname(), false),
|
||||||
|
))
|
||||||
|
.execute(&mut conn)
|
||||||
.await
|
.await
|
||||||
.map_err(ConnectionError::CouldntSetupConfiguration)?;
|
.map_err(ConnectionError::CouldntSetupConfiguration)?;
|
||||||
Ok(conn)
|
Ok(conn)
|
||||||
|
@ -473,7 +479,7 @@ static EMAIL_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
});
|
});
|
||||||
|
|
||||||
pub mod functions {
|
pub mod functions {
|
||||||
use diesel::sql_types::{BigInt, Text, Timestamptz};
|
use diesel::sql_types::{BigInt, Bool, Text, Timestamptz};
|
||||||
|
|
||||||
sql_function! {
|
sql_function! {
|
||||||
#[sql_name = "r.hot_rank"]
|
#[sql_name = "r.hot_rank"]
|
||||||
|
@ -496,6 +502,8 @@ pub mod functions {
|
||||||
|
|
||||||
// really this function is variadic, this just adds the two-argument version
|
// really this function is variadic, this just adds the two-argument version
|
||||||
sql_function!(fn coalesce<T: diesel::sql_types::SqlType + diesel::sql_types::SingleValue>(x: diesel::sql_types::Nullable<T>, y: T) -> T);
|
sql_function!(fn coalesce<T: diesel::sql_types::SqlType + diesel::sql_types::SingleValue>(x: diesel::sql_types::Nullable<T>, y: T) -> T);
|
||||||
|
|
||||||
|
sql_function(fn set_config(setting_name: Text, new_value: Text, is_local: Bool) -> Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const DELETED_REPLACEMENT_TEXT: &str = "*Permanently Deleted*";
|
pub const DELETED_REPLACEMENT_TEXT: &str = "*Permanently Deleted*";
|
||||||
|
|
Loading…
Reference in a new issue