瀏覽代碼

Read both the query argument and the result metadata

Ben Hood 11 年之前
父節點
當前提交
43db64a4a5
共有 3 個文件被更改,包括 10 次插入7 次删除
  1. 2 2
      cassandra_test.go
  2. 5 3
      conn.go
  3. 3 2
      frame.go

+ 2 - 2
cassandra_test.go

@@ -615,8 +615,8 @@ func TestQueryInfo(t *testing.T) {
 		t.Fatalf("Failed to execute query for preparing statement: %v", err)
 	}
 
-	if len(info.rval) == 0 {
-		t.Fatal("Was not expecting to get an empty return value as part of the query info")
+	if len(info.rval) != 2 {
+		t.Fatalf("Was not expecting meta data for %d result columns, but got %d\n", 2, len(info.rval))
 	}
 
 }

+ 5 - 3
conn.go

@@ -330,7 +330,8 @@ func (c *Conn) prepareStatement(stmt string, trace Tracer) (*queryInfo, error) {
 		case resultPreparedFrame:
 			flight.info = &queryInfo{
 				id:   x.PreparedId,
-				args: x.Values,
+				args: x.Arguments,
+				rval: x.ReturnValues,
 			}
 		case error:
 			flight.err = x
@@ -584,8 +585,9 @@ func (c *Conn) decodeFrame(f frame, trace Tracer) (rval interface{}, err error)
 			return resultKeyspaceFrame{keyspace}, nil
 		case resultKindPrepared:
 			id := f.readShortBytes()
-			values, _ := f.readMetaData()
-			return resultPreparedFrame{id, values}, nil
+			args, _ := f.readMetaData()
+			rvals, _ := f.readMetaData()
+			return resultPreparedFrame{PreparedId: id, Arguments: args, ReturnValues: rvals}, nil
 		case resultKindSchemaChanged:
 			return resultVoidFrame{}, nil
 		default:

+ 3 - 2
frame.go

@@ -366,8 +366,9 @@ type resultKeyspaceFrame struct {
 }
 
 type resultPreparedFrame struct {
-	PreparedId []byte
-	Values     []ColumnInfo
+	PreparedId   []byte
+	Arguments    []ColumnInfo
+	ReturnValues []ColumnInfo
 }
 
 type operation interface {