In cqlsh I can execute something like:
SELECT id FROM names WHERE name = 'dave' AND id > maxTimeuuid('2015-04-05 00:05') AND id < minTimeuuid('2019-01-01 00:05');
... this returns a list as expected.
id
--------------------------------------
632f4960-375b-11e8-90b1-02420a000203
91f03523-3761-11e8-a777-02420a000a05
32dbffc4-3762-11e8-a778-02420a000a05
9ffb1ab8-3762-11e8-a779-02420a000a05
c28a0372-3764-11e8-a77b-02420a000a05
However I am struggling to get this to work in gocql:
var found bool = false
m := map[string]interface{}{}
qString := "SELECT id FROM names WHERE name=? AND id > maxTimeuuid(?) AND id < minTimeuuid(?);"
query := Cassandra.Sessionds.Query(qString, name, toFrom.From, toFrom.To).Consistency(gocql.One)
fmt.Println("sending IsRunning query: " + query.String())
iterable := query.Iter()
for iterable.MapScan(m) {
found = true
lookupTable = HostLookup {
Id: m["id"].(gocql.UUID),
}
}
Even though the debug line looks ok,
sending IsRunning query: [query statement="SELECT id FROM names WHERE name=? AND id > maxTimeuuid(?) AND id < minTimeuuid(?);" values=[dave 2015-04-05 00:05 2019-01-01 00:05] consistency=ONE]
... I always end up with an empty iterable. I am using very similar code elsewhere successfully, the difference here are the timeuuid functions. I've tried various arrangements with literal quotes to no avail, any advice is appreciated.
When I looked at the iterable in more detail I found :
"can not marshal string into timestamp"
... this led me to the answer - GoCQL : Marshal string into timestamp