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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user