diff --git a/qb/cmp.go b/qb/cmp.go index f1573b3..a611167 100644 --- a/qb/cmp.go +++ b/qb/cmp.go @@ -90,6 +90,18 @@ func EqNamed(column, name string) Cmp { } } +// EqTupleNamed produces column=(?,?,...) with count number of placeholders and custom name. +func EqTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: eq, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // EqLit produces column=literal and does not add a parameter to the query. func EqLit(column, literal string) Cmp { return Cmp{ @@ -138,6 +150,18 @@ func NeNamed(column, name string) Cmp { } } +// NeTupleNamed produces column!=(?,?,...) with count number of placeholders and custom name. +func NeTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: ne, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // NeLit produces column!=literal and does not add a parameter to the query. func NeLit(column, literal string) Cmp { return Cmp{ @@ -186,6 +210,18 @@ func LtNamed(column, name string) Cmp { } } +// LtTupleNamed produces column<(?,?,...) with count placeholders and custom name. +func LtTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: lt, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // LtLit produces column(?,?,...) with count placeholders and custom name. +func GtTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: gt, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // GtLit produces column>literal and does not add a parameter to the query. func GtLit(column, literal string) Cmp { return Cmp{ @@ -330,6 +390,18 @@ func GtOrEqNamed(column, name string) Cmp { } } +// GtOrEqTupleNamed produces column>=(?,?,...) with count placeholders and custom name. +func GtOrEqTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: geq, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // GtOrEqLit produces column>=literal and does not add a parameter to the query. func GtOrEqLit(column, literal string) Cmp { return Cmp{ @@ -378,6 +450,18 @@ func InNamed(column, name string) Cmp { } } +// InTupleNamed produces column IN ? with a custom parameter name. +func InTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: in, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // InLit produces column IN literal and does not add a parameter to the query. func InLit(column, literal string) Cmp { return Cmp{ @@ -447,6 +531,30 @@ func ContainsKeyNamed(column, name string) Cmp { } } +// ContainsTupleNamed produces column CONTAINS (?,?,...) with count placeholders and custom name. +func ContainsTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: cnt, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + +// ContainsKeyTupleNamed produces column CONTAINS KEY (?,?,...) with count placehplders and custom name. +func ContainsKeyTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: cntKey, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + // ContainsLit produces column CONTAINS literal and does not add a parameter to the query. func ContainsLit(column, literal string) Cmp { return Cmp{ @@ -477,6 +585,18 @@ func LikeTuple(column string, count int) Cmp { } } +// LikeTupleNamed produces column LIKE (?,?,...) with count placeholders and custom name. +func LikeTupleNamed(column string, count int, name string) Cmp { + return Cmp{ + op: like, + column: column, + value: tupleParam{ + param: param(name), + count: count, + }, + } +} + type cmps []Cmp func (cs cmps) writeCql(cql *bytes.Buffer) (names []string) {