diff --git a/enginetest/queries/queries.go b/enginetest/queries/queries.go index 76be51312e..b5bb817511 100644 --- a/enginetest/queries/queries.go +++ b/enginetest/queries/queries.go @@ -6766,6 +6766,10 @@ var QueryTests = []QueryTest{ Query: `select * from mytable where 1 = 0 order by i asc`, Expected: []sql.Row{}, }, + { + Query: `select * from mytable where i not in (1)`, + Expected: []sql.Row{{2, "second row"}, {3, "third row"}}, + }, } var KeylessQueries = []QueryTest{ diff --git a/sql/analyzer/indexes.go b/sql/analyzer/indexes.go index d8bf148234..193f8a2109 100644 --- a/sql/analyzer/indexes.go +++ b/sql/analyzer/indexes.go @@ -15,15 +15,11 @@ package analyzer import ( - errors "gopkg.in/src-d/go-errors.v1" - "github.com/dolthub/go-mysql-server/sql" "github.com/dolthub/go-mysql-server/sql/expression" "github.com/dolthub/go-mysql-server/sql/plan" ) -var errInvalidInRightEvaluation = errors.NewKind("expecting evaluation of IN expression right hand side to be a tuple, but it is %T") - // indexLookup contains an sql.IndexLookup and all sql.Index that are involved // in it. type indexLookup struct { @@ -449,9 +445,12 @@ func getNegatedIndexes( return nil, err } - values, ok := value.([]interface{}) - if !ok { - return nil, errInvalidInRightEvaluation.New(value) + var values []interface{} + switch v := value.(type) { + case []interface{}: + values = v + default: + values = []interface{}{v} } idxBuilder := sql.NewIndexBuilder(ctx, idx)