Manually fix remaining compile warnings.

This commit is contained in:
Magnus Hovland Hoff 2022-04-03 14:19:56 +02:00
parent e0f52cd031
commit 9320d14d89
5 changed files with 8 additions and 28 deletions

View file

@ -40,9 +40,7 @@ fn main() {
));
// Integer is a dummy placeholder. Compiling fails when passing ().
diesel::expression::sql_literal::sql::<(diesel::sql_types::Integer)>(
"PRAGMA foreign_keys = ON",
)
diesel::expression::sql_literal::sql::<diesel::sql_types::Integer>("PRAGMA foreign_keys = ON")
.execute(&connection)
.expect("Should be able to enable foreign keys");

View file

@ -21,7 +21,7 @@ pub mod sqlfunc {
impl CustomizeConnection<SqliteConnection, r2d2_diesel::Error> for SqliteInitializer {
fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), r2d2_diesel::Error> {
sql::<(Integer)>("PRAGMA foreign_keys = ON")
sql::<Integer>("PRAGMA foreign_keys = ON")
.execute(conn)
.map_err(|x| r2d2_diesel::Error::QueryError(x))?;

View file

@ -352,8 +352,6 @@ impl Resource for ChangesResource {
let head = self.head();
Box::new(data.join(head).and_then(move |(mut data, head)| {
use std::iter::Iterator;
let extra_element = if data.len() > self.limit as usize {
data.pop()
} else {

View file

@ -8,15 +8,11 @@ pub struct Error;
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "{}", (self as &dyn error::Error).description())
write!(f, "`after` and `before` are mutually exclusive")
}
}
impl error::Error for Error {
fn description(&self) -> &str {
"`after` and `before` are mutually exclusive"
}
}
impl error::Error for Error {}
#[derive(Deserialize)]
struct PaginationStruct<T> {

View file

@ -92,8 +92,6 @@ fn decide_slug(
&base_slug
};
use crate::schema::article_revisions;
let mut slug = base_slug.to_owned();
let mut disambiguator = 1;
@ -125,8 +123,6 @@ impl<'a> SyncState<'a> {
}
pub fn get_article_slug(&self, article_id: i32) -> Result<Option<String>, Error> {
use crate::schema::article_revisions;
Ok(article_revisions::table
.filter(article_revisions::article_id.eq(article_id))
.filter(article_revisions::latest.eq(true))
@ -140,8 +136,6 @@ impl<'a> SyncState<'a> {
article_id: i32,
revision: i32,
) -> Result<Option<models::ArticleRevision>, Error> {
use crate::schema::article_revisions;
Ok(article_revisions::table
.filter(article_revisions::article_id.eq(article_id))
.filter(article_revisions::revision.eq(revision))
@ -181,8 +175,6 @@ impl<'a> SyncState<'a> {
article_id: i32,
revision: i32,
) -> Result<Option<models::ArticleRevisionStub>, Error> {
use crate::schema::article_revisions;
Ok(self
.query_article_revision_stubs(move |query| {
query
@ -202,8 +194,6 @@ impl<'a> SyncState<'a> {
}
self.db_connection.transaction(|| {
use crate::schema::article_revisions;
Ok(
match article_revisions::table
.filter(article_revisions::slug.eq(slug))
@ -327,8 +317,6 @@ impl<'a> SyncState<'a> {
}
self.db_connection.transaction(|| {
use crate::schema::article_revisions;
let (latest_revision, prev_title, prev_slug, prev_theme) = article_revisions::table
.filter(article_revisions::article_id.eq(article_id))
.order(article_revisions::revision.desc())
@ -424,9 +412,9 @@ impl<'a> SyncState<'a> {
let article_id = {
use diesel::expression::sql_literal::sql;
// Diesel and SQLite are a bit in disagreement for how this should look:
sql::<(diesel::sql_types::Integer)>("INSERT INTO articles VALUES (null)")
sql::<diesel::sql_types::Integer>("INSERT INTO articles VALUES (null)")
.execute(self.db_connection)?;
sql::<(diesel::sql_types::Integer)>("SELECT LAST_INSERT_ROWID()")
sql::<diesel::sql_types::Integer>("SELECT LAST_INSERT_ROWID()")
.load::<i32>(self.db_connection)?
.pop()
.expect("Statement must evaluate to an integer")