Conversation
novln
left a comment
There was a problem hiding this comment.
Destination (or output) is optional in this case, while I agree, most of the time we'll have something.
Using variadic for optional arguments is a known pattern in Go, while it's not the best, I think it's more simple/efficient to use (from an user perspective):
updateStmt := loukoum.Update("users").
Set(loukoum.Pair("username", "novln")).
Where(loukoum.Condition("username").Equal(1234))
makroud.Exec(ctx, driver, updateStmt)
Than,
makroud.Exec(ctx, driver, updateStmt, nil)
I'm not convinced by these changes. While I regret we can't have function overloading for this specific use case.
I don't have a better solution in my mind, but I think we could take advantage of this refactoring to merge RawExec and RawExecArgs, that basically does the same thing and has the same problems.
I would suggest to do the following instead: query, args := loukoum.Update("users").
Set(loukoum.Pair("username", "novln")).
Where(loukoum.Condition("username").Equal(1234)).
Query()
err := driver.Exec(ctx, query, args...)I find it simpler because users just interacts with makroud.Driver, they don't need to interact with both makroud.Driver and makroud.Exec. |
The API of the package is more clear if the dest argument of the Exec function is not variadic. If users want to call the Exec function without a dest argument, they can directly call driver.Exec instead.
12edec7 to
4e0d300
Compare
The API of the package is more clear if the dest argument of the Exec
function is not variadic. If users want to call the Exec function
without a dest argument, they can directly call driver.Exec instead.