dsync icon indicating copy to clipboard operation
dsync copied to clipboard

Derive "diesel::Identifiable" if struct has a primary-key

Open hasezoey opened this issue 1 year ago • 1 comments

This PR adds derive diesel::Identifiable to all Read-structs which have a primary key.

fixes #133

Note: personally i thought the Identifiable is only necessary for Associations or if you want to use the struct directly in a update (see doc quote)

This must be implemented to use associations. Additionally, implementing this trait allows you to pass your struct to update (update(&your_struct) is equivalent to update(YourStruct::table().find(&your_struct.primary_key())

source


@longsleep does this properly fix you case? also could you explain why it would be necessary aside from Associations or is the second "helper"(the update(&struct)) the reason?

hasezoey avatar Feb 12 '24 15:02 hasezoey

@longsleep does this properly fix you case? also could you explain why it would be necessary aside from Associations or is the second "helper"(the update(&struct)) the reason?

Users of the generated structs might need the Identifiable trait in their own code (like to get access to the id function or for other purposes).

longsleep avatar Feb 13 '24 09:02 longsleep