tejaslodayadd commented on code in PR #1924:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1924#discussion_r2784352165


##########
session.go:
##########
@@ -1272,6 +1272,12 @@ func (q *Query) SerialConsistency(cons Consistency) 
*Query {
        return q
 }
 
+// GetSerialConsistency returns the currently configured serial consistency 
level for
+// the query.
+func (q *Query) GetSerialConsistency() Consistency {
+       return q.serialCons
+}

Review Comment:
   If serial consistency was never set, `serialCons` will have its zero value 
which is `ANY` — an invalid serial consistency level. If a user then takes this 
return value and tries to set it on another query via `SerialConsistency()`, 
the driver will panic (since `SerialConsistency` panics on values other than 
`Serial` or `LocalSerial`).
   
   Consider returning `*Consistency` instead so we can return `nil` when serial 
consistency was never explicitly set, and document this behavior in the godoc. 
Something like:
   
   ```go
   // GetSerialConsistency returns the currently configured serial consistency 
level for
   // the query. It returns nil if no serial consistency has been set.
   func (q *Query) GetSerialConsistency() *Consistency {
        if q.serialCons == 0 {
                return nil
        }
        return &q.serialCons
   }
   ```
   
   Same applies to the `Batch.GetSerialConsistency()` below.



-- 
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