Skip to content
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

Proposal: Changing Open and NewTransaction #295

Open
sio4 opened this issue Nov 9, 2018 · 0 comments
Open

Proposal: Changing Open and NewTransaction #295

sio4 opened this issue Nov 9, 2018 · 0 comments
Labels
proposal A suggestion for a change, feature, enhancement, etc
Milestone

Comments

@sio4
Copy link
Member

sio4 commented Nov 9, 2018

Hi, all!
I want to try to make a change on connection.go. The goals are:

  • To support database specific initialization
  • To support database specific transaction handling

(It is indirectly related to #281)

Details

Current ideas are:

For Connection.Open()

Sometimes we need some initial settings for the connected database and sometimes we need to gather some information from the connected server. (such as protocol version, server version,...) I already added some codes for CockroachDB to check the version of engine so we can handle version differences. In my opinion, the best chance to get that information is when we connect to it very first time.

So I will try to add something like:

if err == nil {
    c.Store = &dB{db}
    c.Dialect.ConnectCallBack(c)
}

and with ConnectCallBack(), we can add some database specific codes to initial setup and/or to get some information.

For NewTransaction()

I think transaction handling should be moved to dialect completely since there are some differences on transaction handling.

func (c *Connection) NewTransaction() error {
	return c.Dialect.NewTransaction(c)
}

Especially for CockroachDB, I found that transaction handling code is all of there own driver. (I cannot sure for now we can use that code or not, anyway.) And sometimes, we need to do some action for specific database engine when we get a new session (individual connections) and the NewTransaction() is the best place to do it.

Please think about my proposal and give me your opinions!

Thanks

@sio4 sio4 added the proposal A suggestion for a change, feature, enhancement, etc label Sep 20, 2022
@sio4 sio4 added this to the Proposal milestone Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal A suggestion for a change, feature, enhancement, etc
Projects
None yet
Development

No branches or pull requests

1 participant