Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[applied] on update map missing #612

Closed
ekle opened this issue Jan 28, 2016 · 3 comments
Closed

[applied] on update map missing #612

ekle opened this issue Jan 28, 2016 · 3 comments

Comments

@ekle
Copy link

ekle commented Jan 28, 2016

hi,
the following works with 39654eb.
But after d3c6bee it does not work anymore.

package main

import (
        "log"

        "github.com/gocql/gocql"
)

func main() {
        cluster := gocql.NewCluster("127.0.0.1")
        cluster.Keyspace = "test"
        cluster.Consistency = gocql.Quorum
        cluster.ProtoVersion = 3
        cluster.RetryPolicy = &gocql.SimpleRetryPolicy{NumRetries: 3}
        cluster.Discovery = gocql.DiscoveryConfig{}
        session, err := cluster.CreateSession()
        if err != nil {
                panic(err)
        }
        err = session.Query("CREATE TABLE test.test (k text, v text, PRIMARY KEY(k));").Exec()
        if err != nil {
                log.Print(err.Error())
        }
        err = session.Query("INSERT INTO test.test (k) VALUES ('a')").Exec()
        if err != nil {
                panic(err)
        }
        iter := session.Query("UPDATE test.test USING TTL 1 SET v = 'new' WHERE k = 'a' IF v = ? ", nil).Iter()
        var raw = make(map[string]interface{})                                                     

        for iter.MapScan(raw) {                                                        
                log.Print(raw)                                                         
                if _, found := raw["[applied]"]; found {
                        log.Print("OK")
                        return
                }      
        }              
        log.Print("BUG")
} 
@Zariel
Copy link
Member

Zariel commented Jan 28, 2016

You should use MapScanCAS to do the CAS operation

@Zariel
Copy link
Member

Zariel commented Jan 28, 2016

This is because for some reason when preparing a CAS statement Cassandra does not include the applied column, but when you execute the query it is included in the response metadata, which we skip for non-cas operations. Im not sure if this is a bug in Cassandra or not.

@Zariel
Copy link
Member

Zariel commented Feb 5, 2016

@ekle call NoSkipMetadata on the query will fix this.

@Zariel Zariel closed this as completed Feb 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants