Browse Source

Format some SQL queries better

master
Alex Mikhalev 4 years ago
parent
commit
e5a2e169a2
  1. 5
      src/main.rs
  2. 4
      src/migrations.rs

5
src/main.rs

@ -34,7 +34,10 @@ fn setup_db() -> Result<DbConnection> { @@ -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 {

4
src/migrations.rs

@ -85,7 +85,9 @@ pub fn get_db_version(conn: &Connection) -> MigrationResult<MigrationVersion> { @@ -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),
)?;

Loading…
Cancel
Save