Format some SQL queries better

This commit is contained in:
Alex Mikhalev 2020-09-20 14:52:57 -06:00
parent aed95202ce
commit e5a2e169a2
2 changed files with 7 additions and 2 deletions

View File

@ -34,7 +34,10 @@ fn setup_db() -> Result<DbConnection> {
}
fn query_sections(conn: &DbConnection) -> Result<Sections> {
let mut statement = conn.prepare_cached("SELECT id, name, interface_id FROM sections;")?;
let mut statement = conn.prepare_cached(
"SELECT s.id, s.name, s.interface_id \
FROM sections AS s;",
)?;
let rows = statement.query_map(NO_PARAMS, Section::from_sql)?;
let mut sections = Sections::new();
for row in rows {

View File

@ -85,7 +85,9 @@ pub fn get_db_version(conn: &Connection) -> MigrationResult<MigrationVersion> {
}
let version: u32 = conn.query_row(
"SELECT version FROM db_version WHERE id = 1",
"SELECT v.version \
FROM db_version AS v \
WHERE id = 1",
NO_PARAMS,
|row| row.get(0),
)?;