Add support for BYPASS CACHE
This commit adds support for BYPASS CACHE extension that is present in ScyllaDB since 3.1 / 2019.1.1. https://docs.scylladb.com/getting-started/dml/#bypass-cache
This commit is contained in:
committed by
Michal Matczuk
parent
dd98b0e363
commit
75adfd59ee
14
qb/select.go
14
qb/select.go
@@ -40,6 +40,7 @@ type SelectBuilder struct {
|
||||
limit uint
|
||||
limitPerPartition uint
|
||||
allowFiltering bool
|
||||
bypassCache bool
|
||||
json bool
|
||||
}
|
||||
|
||||
@@ -109,6 +110,10 @@ func (b *SelectBuilder) ToCql() (stmt string, names []string) {
|
||||
cql.WriteString("ALLOW FILTERING ")
|
||||
}
|
||||
|
||||
if b.bypassCache {
|
||||
cql.WriteString("BYPASS CACHE ")
|
||||
}
|
||||
|
||||
stmt = cql.String()
|
||||
return
|
||||
}
|
||||
@@ -180,6 +185,15 @@ func (b *SelectBuilder) AllowFiltering() *SelectBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
// BypassCache sets a BYPASS CACHE clause on the query.
|
||||
//
|
||||
// BYPASS CACHE is a feature specific to ScyllaDB.
|
||||
// See https://docs.scylladb.com/getting-started/dml/#bypass-cache
|
||||
func (b *SelectBuilder) BypassCache() *SelectBuilder {
|
||||
b.bypassCache = true
|
||||
return b
|
||||
}
|
||||
|
||||
// Count produces 'count(column)'.
|
||||
func (b *SelectBuilder) Count(column string) *SelectBuilder {
|
||||
b.fn("count", column)
|
||||
|
||||
@@ -128,6 +128,18 @@ func TestSelectBuilder(t *testing.T) {
|
||||
S: "SELECT * FROM cycling.cyclist_name WHERE id=? ALLOW FILTERING ",
|
||||
N: []string{"expr"},
|
||||
},
|
||||
// Add ALLOW FILTERING and BYPASS CACHE
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Where(w).AllowFiltering().BypassCache(),
|
||||
S: "SELECT * FROM cycling.cyclist_name WHERE id=? ALLOW FILTERING BYPASS CACHE ",
|
||||
N: []string{"expr"},
|
||||
},
|
||||
// Add BYPASS CACHE
|
||||
{
|
||||
B: Select("cycling.cyclist_name").Where(w).BypassCache(),
|
||||
S: "SELECT * FROM cycling.cyclist_name WHERE id=? BYPASS CACHE ",
|
||||
N: []string{"expr"},
|
||||
},
|
||||
// Add COUNT all
|
||||
{
|
||||
B: Select("cycling.cyclist_name").CountAll().Where(Gt("stars")),
|
||||
|
||||
Reference in New Issue
Block a user