worryg0d commented on code in PR #1778:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1778#discussion_r1756289244


##########
cassandra_test.go:
##########
@@ -3288,3 +3288,46 @@ func TestQuery_NamedValues(t *testing.T) {
                t.Fatal(err)
        }
 }
+
+func TestBatchKeyspaceField(t *testing.T) {
+       session := createSession(t)
+       defer session.Close()
+
+       if session.cfg.ProtoVersion < protoVersion5 {
+               t.Skip("keyspace for BATCH message is not supported in protocol 
< 5")
+       }
+
+       err := createTable(session, "CREATE TABLE batch_keyspace(id int, value 
text, PRIMARY KEY (id))")
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       ids := []int{1, 2}
+       texts := []string{"val1", "val2"}
+
+       b := session.NewBatch(LoggedBatch)
+       b.Query("INSERT INTO batch_keyspace(id, value) VALUES (?, ?)", ids[0], 
texts[0])

Review Comment:
   As far as I see from the [proto 5 
spec](https://github.com/apache/cassandra/blob/985fd2931a5c13ba5e3809ce327dac078212fc83/doc/native_protocol_v5.spec#L617)
 we can not override the keyspace for the specific query in the Batch, only for 
the Batch itself.
   
   ```
   4.1.7. BATCH
   
     Allows executing a list of queries (prepared or not) as a batch (note that
     only DML statements are accepted in a batch). The body of the message must
     be:
       
<type><n><query_1>...<query_n><consistency><flags>[<serial_consistency>][<timestamp>][<keyspace>][<now_in_seconds>]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to