Przeglądaj źródła

Add comment the motivation of MapScanCAS()

ono_matope 11 lat temu
rodzic
commit
7d118cdcd0
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      session.go

+ 5 - 1
session.go

@@ -350,7 +350,11 @@ func (q *Query) ScanCAS(dest ...interface{}) (applied bool, err error) {
 // MapScanCAS executes a lightweight transaction (i.e. an UPDATE or INSERT
 // statement containing an IF clause). If the transaction fails because
 // the existing values did not match, the previos values will be stored
-// in dest.
+// in dest map.
+//
+// As for INSERT .. IF NOT EXISTS, previous values will be returned as if
+// SELECT * FROM. So using ScanCAS with INSERT is inherently prone to
+// column mismatching. MapScanCAS is added to capture them safely.
 func (q *Query) MapScanCAS(dest map[string]interface{}) (applied bool, err error) {
 	iter := q.Iter()
 	if err := iter.checkErrAndNotFound(); err != nil {