Support for literals in INSERT and UPDATE and comparisons

The 'value' interface represents a CQL value for use in a comparison,
update, or intitialization operation. A consistent interface for this
allows us to easily support specifying default-named, custom-named,
literal, and evaluated-function values in all these contexts.

Parameters to Func should probably also be values to support full
composition, but that would be a breaking change because Func's
properties are exposed.

The value interface could itself be exposed if we wanted to allow
clients to pass their own values to SetValue, etc, but for now it is a
package-internal abstraction.

BLA
This commit is contained in:
Josh Giles
2017-10-29 13:18:49 -04:00
committed by Michał Matczuk
parent 9fa5432a65
commit 12d360a0c3
8 changed files with 286 additions and 63 deletions

View File

@@ -91,6 +91,36 @@ func TestCmp(t *testing.T) {
N: []string{"name"},
},
// Literals
{
C: EqLit("eq", "litval"),
S: "eq=litval",
},
{
C: LtLit("lt", "litval"),
S: "lt<litval",
},
{
C: LtOrEqLit("lt", "litval"),
S: "lt<=litval",
},
{
C: GtLit("gt", "litval"),
S: "gt>litval",
},
{
C: GtOrEqLit("gt", "litval"),
S: "gt>=litval",
},
{
C: InLit("in", "litval"),
S: "in IN litval",
},
{
C: ContainsLit("cnt", "litval"),
S: "cnt CONTAINS litval",
},
// Functions
{
C: EqFunc("eq", Fn("fn", "arg0", "arg1")),