Wulf / dsync

Generate rust structs & query functions from diesel schema files
Other
70 stars 13 forks source link

feat(code): add options "create-bytes" and "update-bytes" #123

Closed thwyr closed 9 months ago

thwyr commented 9 months ago

Add feature flags for reference- and cow- types for byte blobs in update/create akin to the feature flags for string types.

This allows one to avoid additional allocations or moves in Create and Update structs when dealing with byte blobs similar to allocations avoided by using &str and Cow with strings.

thwyr commented 9 months ago

I should have fixed up everything at this point; I apologize for the half-assed nature of the initial PR.

Looking at the code now, I'm convinced that there is a compelling argument to merge the two into a single flag; I struggle to think of a situation where the user wants to avoid moves/allocations for Strings but not for Vec. This would also avoid the need for testing that the lifetime string is correct in the generated struct when both are present.

thwyr commented 9 months ago

This PR looks good now, thanks for the work (i at least dont see any issues, but the test output is currently not compile-tested, see #114)

Thanks. It looks like the compile-testing is a WIP. I can revisit adding that onto this once I have a merged example to work with.

i guess you could say that, but this is for the future and if changed, then likely will only be changed for the main.rs configuration (because why change the library one, if it already exists and is not much burden and so has more configurability?)

My main motivation would be to simplify the library code; there is something to be said for configurability being meaningless if it's not actually put to use.

Having said that, I've already scratched my itch. I also have a follow-up commit documenting the flags.