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

Add sqlx.Conn to correspond to sql.Conn #421

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andeya
Copy link

@andeya andeya commented Jun 13, 2018

Requires version: go ≥ 1.9

@coveralls
Copy link

coveralls commented Jun 13, 2018

Pull Request Test Coverage Report for Build 30

  • 0 of 58 (0.0%) changed or added relevant lines in 1 file are covered.
  • 80 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-2.7%) to 69.147%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sqlx_conn.go 0 58 0.0%
Files with Coverage Reduction New Missed Lines %
reflectx/reflect.go 80 97.67%
Totals Coverage Status
Change from base Build 17: -2.7%
Covered Lines: 1078
Relevant Lines: 1559

💛 - Coveralls

@andeya andeya closed this Jun 13, 2018
@andeya andeya reopened this Jun 13, 2018
@andeya andeya changed the title Add sqlx.Connx to correspond to sql.Conn Add sqlx.Conn to correspond to sql.Conn Jun 13, 2018
@jmoiron
Copy link
Owner

jmoiron commented Jun 13, 2018

Nice contribution. I'd like to add some testing and perhaps get vgo integration going before I leave some verisons of Go behind.

@andeya
Copy link
Author

andeya commented Jun 14, 2018

The test just like this:

type Stat struct {
	Uri       string `db:"uri"`
	Total     int64  `db:"total"`
	CreatedAt int64  `db:"created_at"`
}

func TestDBConn(t *testing.T) {
	conn, err := db.Conn(context.Background())
	if err != nil {
		t.Fatal(err)
	}
	defer conn.Close()
	var total int64 = 1
	r, err := conn.ExecContext(
		context.Background(),
		`INSERT INTO stat VALUE ('/j',?,1528996897)
		ON DUPLICATE KEY UPDATE total=@total_tmp:=total+?;`,
		total, 1,
	)
	if err != nil {
		t.Fatal(err)
	}
	rowsAffected, err := r.RowsAffected()
	if err != nil {
		t.Fatal(err)
	}
	if rowsAffected == 2 {
		err = conn.GetContext(context.Background(), &total, "SELECT @total_tmp as total;")
		if err != nil {
			t.Fatal(err)
		}
	}
	t.Log(total)
}

@glaslos
Copy link
Contributor

glaslos commented Oct 15, 2018

@henrylee2cn how about adding your test to the PR?

@dlsniper dlsniper added could merge The PR look safe enough to merge needs testing The PR needs more testing before being accepted labels Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
could merge The PR look safe enough to merge needs testing The PR needs more testing before being accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants