golistic / pxmysql

Go MySQL driver using X Protocol
MIT License
14 stars 0 forks source link

Session as high-level connection object #57

Closed geertjanvdk closed 1 year ago

geertjanvdk commented 1 year ago

We currently first create a Connection object, and then instantiate Session object from it. This should not be the case.

Examples can be found for other programming languages in the MySQL manual: https://dev.mysql.com/doc/x-devapi-userguide/en/working-with-a-session-object.html

Instead of doing:

    cnx, err := xmysql.NewConnection(config)
    if err != nil {
        log.Fatal(err)
    }

    ses, err := cnx.NewSession(context.Background())
    if err != nil {
        log.Fatal(err)
    }

We must do it like this (one step less):

    ses, err := xmysql.NewSession(context.Background(), config)
    if err != nil {
        log.Fatal(err)
    }

We will be using the Create-prefix instead of New so it is inline with other implementation of the MySQL X DevAPI.

This is a breaking change, but since we have no production release yet, we allow this.

It is not a breaking change for the Go SQL-driver.