Browse Source

Inherit consistency from session in NewBatch

When creating a batch from a session, inherit the consistency from
the session.

Fixes #355
Chris Bannister 10 years ago
parent
commit
cd7d08d825
1 changed files with 4 additions and 1 deletions
  1. 4 1
      session.go

+ 4 - 1
session.go

@@ -734,7 +734,10 @@ func NewBatch(typ BatchType) *Batch {
 
 // NewBatch creates a new batch operation using defaults defined in the cluster
 func (s *Session) NewBatch(typ BatchType) *Batch {
-	return &Batch{Type: typ, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency}
+	s.mu.RLock()
+	batch := &Batch{Type: typ, rt: s.cfg.RetryPolicy, serialCons: s.cfg.SerialConsistency, Cons: s.cons}
+	s.mu.RUnlock()
+	return batch
 }
 
 // Attempts returns the number of attempts made to execute the batch.