Wulf / dsync

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

Improve Code generation #105

Open hasezoey opened 11 months ago

hasezoey commented 11 months ago

Currently code generation is basically done by string concatenation, which is "good enough" but could be improved, current suggestions are:

Wulf commented 11 months ago

Thanks for creating this -- I like the idea of using quote as it's closer to rust code, but I'm afraid it'll be harder for newcomers to come in and contribute as they'll have to understand quote's intricacies instead of just manipulating strings. That being said, it'll be one step closer to always producing correct code.

Wulf commented 11 months ago

At the same time, Tera is quite heavy for something as simple as doing codegen, so I'm with you there.

hasezoey commented 11 months ago

but I'm afraid it'll be harder for newcomers to come in and contribute as they'll have to understand quote's intricacies instead of just manipulating strings.

as a counter point: we are already using quote / syn (not its macros though) to parse the input file, so we have to already deal with a little quote stuff and personally, i have not used quotes macros before, but its syntax looks really simple (if you know rust code)

Wulf commented 11 months ago

Although we're using quote/syn to parse rust code, it can be confusing for newcomers, especially the 'repetition' syntax. I don't mind giving it a shot though! We can revert if necessary :-)