sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

adds support for structscan in multiple resultset queries

Open basvanbeek opened this issue 6 years ago • 5 comments

StructScan fails in a multiple result set scenario when the result sets have different row layouts.

Currently sqlx is unaware of iteration over multiple result sets and uses the first call to StructScan to set a field cache for performance reasons. When a next result set is iterated over, this field cache will most likely not match the struct provided.

By wrapping the NextResultSet method from sql.Rows and setting the field cache started property back to false the problem is solved.

basvanbeek avatar Sep 23 '18 21:09 basvanbeek

Pull Request Test Coverage Report for Build 101

  • 3 of 5 (60.0%) changed or added relevant lines in 1 file are covered.
  • 240 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-4.7%) to 67.144%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sqlx.go 3 5 60.0%
<!-- Total: 3 5
Files with Coverage Reduction New Missed Lines %
bind.go 20 77.7%
sqlx_context.go 24 58.64%
named.go 44 78.4%
sqlx.go 72 63.45%
reflectx/reflect.go 80 66.54%
<!-- Total: 240
Totals Coverage Status
Change from base Build 32: -4.7%
Covered Lines: 985
Relevant Lines: 1467

💛 - Coveralls

coveralls avatar Sep 23 '18 22:09 coveralls

@jmoiron friendly ping. any feedback?

basvanbeek avatar May 18 '19 13:05 basvanbeek

@jmoiron is there a way forward on merging this PR? This fixes a critical issue for, what to me is, a common use case.

jpeirson avatar Mar 05 '20 18:03 jpeirson

FYI; we've started using this branch @basvanbeek works great 👍

Dynom avatar Oct 14 '20 08:10 Dynom

Hello, @ardan-bkennedy, and I recently stepped in to help maintain this project. We are sorting the opened issues and I think this can be closed in favor of #747. Thank you for your contribution.

dlsniper avatar Feb 01 '24 14:02 dlsniper