Skip to content

Commit b76df56

Browse files
committed
Rewrite #[derive(Identifiable)] in derives2
The actual derive itself is pretty straightforward (this isn't exactly a complex trait). Most of the tests were brought over from the macro tests. I dropped a few that were obviously redundant (that were testing our struct parser not the derive). I've added a few for things that weren't working before (and were actually broken) like tuple structs. This does contain what is technically a breaking change in behavior. The old implementation would look for the PK fields by field name rather than column name. I consider this a bug. Everything else links by column name, and if we actually went by field name, tuple structs couldn't work. I didn't add explicit UI tests for the table not being in scope, or for bad syntax, as those are redundant with AsChangeset. We did have to do a little bit of dancing to work around rust-lang/rust#47941 when the PK names cause an error.
1 parent 0b0b1e8 commit b76df56

16 files changed

Lines changed: 318 additions & 414 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
5454
old and new timestamp formats. (The migrations were always run in the correct
5555
order, this only affects the display logic of `migration list`)
5656

57+
* `#[derive(Identifiable)]` now correctly associates `#[primary_key]` with the
58+
column name, not field name.
59+
5760
## [1.1.1] - 2018-01-16
5861

5962
### Added

diesel/src/macros/identifiable.rs

Lines changed: 0 additions & 365 deletions
This file was deleted.

diesel/src/macros/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,8 +1143,6 @@ mod static_cond;
11431143
#[macro_use]
11441144
mod ops;
11451145

1146-
#[macro_use]
1147-
mod identifiable;
11481146
#[macro_use]
11491147
mod insertable;
11501148

diesel_compile_tests/tests/compile-fail/identifiable_requires_primary_key_field.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)