2
0

Add CommandTag to Rows interface

This allows handling queries where it is unknown if there will be a
result set or not. If it is not a result set returning query the
command tag will still be available.
This commit is contained in:
Jack Christensen
2019-09-02 09:53:26 -05:00
parent 0ef89ae0b7
commit b5ce0220f8
3 changed files with 43 additions and 11 deletions
+15
View File
@@ -48,6 +48,8 @@ func TestConnQueryScan(t *testing.T) {
t.Fatalf("conn.Query failed: %v", err)
}
assert.Equal(t, "SELECT 10", string(rows.CommandTag()))
if rowCount != 10 {
t.Error("Select called onDataRow wrong number of times")
}
@@ -56,6 +58,19 @@ func TestConnQueryScan(t *testing.T) {
}
}
func TestConnQueryWithoutResultSetCommandTag(t *testing.T) {
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
defer closeConn(t, conn)
rows, err := conn.Query(context.Background(), "create temporary table t (id serial);")
assert.NoError(t, err)
rows.Close()
assert.NoError(t, rows.Err())
assert.Equal(t, "CREATE TABLE", string(rows.CommandTag()))
}
func TestConnQueryScanWithManyColumns(t *testing.T) {
t.Parallel()