Fix: FieldDescriptions are available on Rows before calling Next

pull/828/head
Jack Christensen 2020-09-05 13:24:57 -05:00
parent 2ec377350b
commit d4a300bd58
3 changed files with 17 additions and 1 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.12
require (
github.com/cockroachdb/apd v1.1.0
github.com/gofrs/uuid v3.2.0+incompatible
github.com/jackc/pgconn v1.6.5-0.20200821030840-fdfc783345f6
github.com/jackc/pgconn v1.6.5-0.20200905181414-0d4f029683fc
github.com/jackc/pgio v1.0.0
github.com/jackc/pgproto3/v2 v2.0.4
github.com/jackc/pgtype v1.4.3-0.20200905161353-e7d2b057a716

2
go.sum
View File

@ -44,6 +44,8 @@ github.com/jackc/pgconn v1.6.5-0.20200821030021-3eb5432c4738 h1:t/IRFEw2da5v6Dro
github.com/jackc/pgconn v1.6.5-0.20200821030021-3eb5432c4738/go.mod h1:gm9GeeZiC+Ja7JV4fB/MNDeaOqsCrzFiZlLVhAompxk=
github.com/jackc/pgconn v1.6.5-0.20200821030840-fdfc783345f6 h1:7f1RmJO6KZI4cskLrNHBd5CCLmLpIQ0BD75hsorvdz8=
github.com/jackc/pgconn v1.6.5-0.20200821030840-fdfc783345f6/go.mod h1:gm9GeeZiC+Ja7JV4fB/MNDeaOqsCrzFiZlLVhAompxk=
github.com/jackc/pgconn v1.6.5-0.20200905181414-0d4f029683fc h1:9ThyBXKdyBFN2Y1NSCPGCA0kdWCNpd9u4SKWwtr6GfU=
github.com/jackc/pgconn v1.6.5-0.20200905181414-0d4f029683fc/go.mod h1:gm9GeeZiC+Ja7JV4fB/MNDeaOqsCrzFiZlLVhAompxk=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2 h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA=

View File

@ -59,6 +59,20 @@ func TestConnQueryScan(t *testing.T) {
}
}
func TestConnQueryRowsFieldDescriptionsBeforeNext(t *testing.T) {
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, conn)
rows, err := conn.Query(context.Background(), "select 'hello' as msg")
require.NoError(t, err)
defer rows.Close()
require.Len(t, rows.FieldDescriptions(), 1)
assert.Equal(t, []byte("msg"), rows.FieldDescriptions()[0].Name)
}
func TestConnQueryWithoutResultSetCommandTag(t *testing.T) {
t.Parallel()