diff --git a/.deepsource.toml b/.deepsource.toml index 2a04c852..1418a25c 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -1,6 +1,6 @@ version = 1 -test_patterns = [ - "butane/tests/**", +test_patterns = [ + "butane/tests/**", ] [[analyzers]] diff --git a/.editorconfig b/.editorconfig index 299cce5a..78672e0d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,6 +5,7 @@ root = true end_of_line = lf insert_final_newline = true max_line_length = 120 +trim_trailing_whitespace = true [butane_cli/src/main.rs] max_line_length = 400 diff --git a/README.md b/README.md index 5c9f7dcb..347360b1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ implementation detail to the API consumer. * Ability to embed migrations in Rust code (so that a library may easily bundle its migrations) * SQLite and PostgreSQL backends * Write entirely or nearly entirely the same code regardless of database backend - + ## Getting Started _Models_, declared with struct attributes define the database diff --git a/butane_core/src/db/pg.rs b/butane_core/src/db/pg.rs index d7b084bd..19d1fad0 100644 --- a/butane_core/src/db/pg.rs +++ b/butane_core/src/db/pg.rs @@ -594,6 +594,13 @@ fn define_column(col: &AColumn) -> Result { if col.unique() { constraints.push("UNIQUE".to_string()); } + if constraints.is_empty() { + return Ok(format!( + "{} {}", + helper::quote_reserved_word(col.name()), + col_sqltype(col)?, + )); + } Ok(format!( "{} {} {}", helper::quote_reserved_word(col.name()), diff --git a/docs/getting-started.md b/docs/getting-started.md index c2832754..9c7eac8a 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -337,8 +337,7 @@ fn main() { println!("{}", post.title); println!("----------\n"); println!("{}", post.body); - - } + } } ``` diff --git a/examples/getting_started/.butane/migrations/20201229_144636751_init/pg_up.sql b/examples/getting_started/.butane/migrations/20201229_144636751_init/pg_up.sql index 00d311c8..536c949e 100644 --- a/examples/getting_started/.butane/migrations/20201229_144636751_init/pg_up.sql +++ b/examples/getting_started/.butane/migrations/20201229_144636751_init/pg_up.sql @@ -8,7 +8,7 @@ title TEXT NOT NULL, body TEXT NOT NULL, published BOOLEAN NOT NULL, blog BIGINT NOT NULL, -byline TEXT +byline TEXT ); CREATE TABLE Post_tags_Many ( owner INTEGER NOT NULL,