-
Notifications
You must be signed in to change notification settings - Fork 374
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
Gorp new sql context support #344
Comments
@soniabhishek Heya -- any updates on this? I think it would be nice to have that. |
d'oh, this is probably something I should have commented on. There are no current plans, but feel free! If you don't get to it, I'll keep it in mind for the rearch I've been working through. |
I'm also interested in this as I've just started using tracing libraries. If I had some guidance on the desired API, I may be able to take a swing at it. |
Looks like it might be pretty simple to pipe through. What are you thinking in terms of the change to the API? (1) Add new
(2) Add a
(3) I guess it's possible to do something backward incompatible that forces context, but I assume that's not desirable. (1) is probably most similar to how go changed the underlying sql.Db, but it add the most new methods. |
I would currently choose #2. I have ideas to mess with the syntax to make
gorp more flexible, but that'll be for later. For now, returning a new
SqlExecutor that uses the context is probably the best choice.
In the distant future, I have a really vague thought of something like
`dbmap.Query(someSQL, gorp.Args(arg1, arg2, arg3), gorp.WithContext(ctx),
gorp.SomeOtherCoolOption()).Unmarshal(&foo,
gorp.SomeCoolUnmarshalOption())`.
But for now, #2.
On Aug 30, 2017 18:46, "Matthew Dolan" <[email protected]> wrote:
Looks like it might be pretty simple to pipe through.
What are you thinking in terms of the change to the API?
(1) Add new FooContext methods that copy the existing methods.
type SqlExecutor interface {
Get(i interface{}, keys ...interface{}) (interface{}, error)
GetContext(ctx context.Context, i interface{}, keys ...interface{})
(interface{}, error)
Insert(list ...interface{}) error
InsertContext(ctx context.Context, list ...interface{}) error
Update(list ...interface{}) (int64, error)
UpdateContext(ctx context.Context, list ...interface{}) (int64, error)
Delete(list ...interface{}) (int64, error)
DeleteContext(ctx context.Context, list ...interface{}) (int64, error)
Exec(query string, args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...interface{})
(sql.Result, error)
...
}
(2) Add a WithContext(ctx) which attaches the context to the dbMap.
type SqlExecutor interface {
WithContext(ctx context.Context) SqlExecutor
Get(i interface{}, keys ...interface{}) (interface{}, error)
Insert(list ...interface{}) error
Update(list ...interface{}) (int64, error)
Delete(list ...interface{}) (int64, error)
Exec(query string, args ...interface{}) (sql.Result, error)
...
}
(3) I guess it's possible to do something backward incompatible that forces
context, but I assume that's not desirable.
(1) is probably most similar to how go changed the underlying sql.Db, but
it add the most new methods.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#344 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA-QBDn3zi_so5fO7qxyjrXGvyTCrGZCks5sdgJ8gaJpZM4MLQAc>
.
|
@soniabhishek yeah, the |
This is merged. @nelsam would it be possible to get a new release (2.1.0) associated with this? |
Sure thing, I'll do that a little bit later today (ideally) |
So, WithContext does return a new Gorp with a context, but the SQLs won't be executed with that ctx apparently? |
Hey when are we expecting to support context for gorp and if no one else is working can I give it a try, It seems easy to workaround.
The text was updated successfully, but these errors were encountered: