-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New "editor" helper to avoid column lists for simple inserts/updates #629
Conversation
This is actually an interesting idea as my own project is covered with these sorts of repetitive lists. My main concern is that it will add a lot of additional generated code and yet another magic struct field (having to have L & R are bad enough). I think if we wanted to accept this proposal to avoid the additional magic struct field we'd do: models.EditUser(u).Username("hello").Update(...)
// instead of:
u.E().Username("hello").Update(...) What do you think? |
|
So I'm remiss @falconandy and must apologize. For delaying this for such a long time. I honestly haven't been able to respond because this feature has me very torn. In terms of pros and cons it looks like this to me: Pros:
Cons:
When we first created sqlboiler one thing we really wanted was that Go like feel. We just wanted to use plain structs because that's a very natural way to code in Go. We wanted normal-ish types (null package sucks but necessary evil in this language) and I think it does make it fairly nice to work with. This does bend that a little bit. Having said that the idea isn't really bad, and there is some safety for those who would choose it. I'd invite some of our contributors to have a say on the feature because I'm having a very difficult time determining if it should make it in myself. @nadilas, @glerchundi, @ceshihao, @gemscng if any of you have comments or want to slap the +1 -1 button on this comment please do so. |
I am ok if it is not breaking one. My only concern is more and more generated codes. It will make a slow build or large binary, even if most of codes are actually not used in my app. Maybe some hugh changes could be implemented in a tailorable way. |
That's a good point. It could be a flag option as we have for G/P/Context. It's default state would be up for debate of course. |
Thanks @aarondl invite me. Whitelist only need if we use has a non-nullable boolean field default to true. In most cases, we only need to use infer. Introducing unnecessary newpattern will make the library harder and harder to maintain. Current go-like way is fine. |
Thank you all for feedback. I'll do it in a separate repository |
@falconandy I appreciate the attempt. It was quite a good idea. I think you'll benefit a lot from using it in your own projects. Consider publishing them as an alternative to our default templates :) |
Motivation
Allow to avoid boring column list in inserts/updates (especially if we want to process empty strings, false values, zeros).
The initial commit doesn't add documentation/tests and doesn't contain InsertG/UpdateG, InsertP/UpdateP implementation. I'll add it later if the new concept will be approved.
Current code
Suggested code
Suggested code (multi-line)
Generated code