Skip to content

Commit

Permalink
Prevent unnecessary whitespace in sqlite SQL (Electron100#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb authored Mar 23, 2024
1 parent 62d9beb commit f431f70
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions butane_core/src/db/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,20 @@ fn define_column(col: &AColumn) -> String {
if col.unique() {
constraints.push("UNIQUE".to_string());
}
format!(
"{} {} {}",
helper::quote_reserved_word(col.name()),
col_sqltype(col),
constraints.join(" ")
)
if constraints.is_empty() {
format!(
"{} {}",
helper::quote_reserved_word(col.name()),
col_sqltype(col),
)
} else {
format!(
"{} {} {}",
helper::quote_reserved_word(col.name()),
col_sqltype(col),
constraints.join(" ")
)
}
}

fn define_constraint(column: &AColumn) -> String {
Expand Down

0 comments on commit f431f70

Please sign in to comment.