-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Eager query method & Clean options for eager loading. #73
Conversation
Clean eager fields slice after every SQL command execution
connection.go
Outdated
@@ -182,6 +182,12 @@ func (c *Connection) Q() *Query { | |||
return Q(c) | |||
} | |||
|
|||
// eagerDisabled disables eager mode for current connection. | |||
func (c *Connection) eagerDisabled() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larrymjordan should this be called something like "disableEager" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paganotoni yes, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fast fix, that's awesome! I just tested the changes, and my problems are solved. 👍
I'm just a bit curious about this specific use-case: if I use the same connection in two or more goroutines in parallel (let's say I want to use eager creation in these goroutines), does it work? As I understand the way it works, if an eager creation finishes just before a parallel creation goes to check the eager flag, the eager mode will be disabled for the second goroutine.
@stanislas-m @larrymjordan I'm also concerned about storing "state" information on the connection. How do we solve this problem? Is this PR safe to merge, while a solution is found? or should this PR wait? You both know more on the subject than I do so I'm going to trust you two. :) |
@markbates @larrymjordan Well, if the eager options on connection are used just for querying, how about removing them from the Using Edit: Eager creation seems using the eager attributes at a connection level. So, how about cloning the connection when using |
My first reaction was copying transaction too. But I think returning a query is better, but it’s a breaking change. I think what someone really needs to do is write up an issue describing how this feature should work, including different use cases, etc… |
@markbates @stanislas-m The reason why |
@larrymjordan As I proposed, I think for |
@stanislas-m can you take a look when you have the chance to my last commit, is that what you suggested? |
@larrymjordan Sure, I'll take a look in a few minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me. 👍
@larrymjordan @stanislas-m great work!! |
@larrymjordan @stanislas-m just ran into the underlying bug -- thanks so much for taking the time to produce a fix! |
Hi @markbates this solves issue #72