Skip to content

Commit 40c4e36

Browse files
authored
Merge pull request diesel-rs#1467 from diesel-rs/sg-empty-infer-schema
Compile successfully when `infer_schema!` is used with an empty database
2 parents 5dad5af + a866ee0 commit 40c4e36

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
2626
* Deprecated specifying a column name as `#[column_name(foo)]`. `#[column_name =
2727
"foo"]` should be used instead.
2828

29+
### Fixed
30+
31+
* `infer_schema!` generates valid code when run against a database with no
32+
tables.
33+
2934
## [1.0.0] - 2018-01-02
3035

3136
### Added

diesel/src/macros/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,8 @@ macro_rules! allow_tables_to_appear_in_same_query {
10791079
};
10801080

10811081
($last_table:ident,) => {};
1082+
1083+
() => {};
10821084
}
10831085

10841086
#[macro_export]

diesel_tests/tests/schema.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ infer_schema!("dotenv:MYSQL_DATABASE_URL");
1111
#[cfg(not(feature = "backend_specific_database_url"))]
1212
infer_schema!("dotenv:DATABASE_URL");
1313

14+
#[cfg(feature = "sqlite")]
15+
mod test_infer_schema_works_on_empty_database {
16+
infer_schema!(":memory:");
17+
}
18+
1419
#[derive(PartialEq, Eq, Debug, Clone, Queryable, Identifiable, Insertable, AsChangeset,
1520
Associations, QueryableByName)]
1621
#[table_name = "users"]

0 commit comments

Comments
 (0)