Skip to content

Add IN and NOT_IN operators for multi-value equality matching #53

@jtnelson

Description

@jtnelson

Summary

Add support for IN and NOT_IN operators that test whether a value equals any value in a provided set. This is a shorthand for multiple OR'd equality checks.

// Instead of:
find name = "Jeff" or name = "John" or name = "Jane"

// Users can write:
find name in ["Jeff", "John", "Jane"]

Motivation

When users need to match a field against several discrete values, they currently must chain multiple = conditions with or. This is verbose, error-prone, and scales poorly as the value list grows. An IN operator is a well-understood concept (SQL, most query languages) that directly expresses this intent.

Design

Operator

  • IN — returns true if the field value equals any value in the provided set
  • NOT_IN — returns true if the field value does not equal any value in the provided set

Arity

This is the first variable-arity operator. BETWEEN is fixed at 2 operands; IN accepts 1 or more. The operands() method on the operator type will need to express this (e.g., return -1 or a sentinel value to indicate variadic).

CCL Syntax

Value list syntax: square brackets with comma-separated values.

find name in ["Jeff", "John", "Jane"]
find age in [18, 21, 25]
find status not_in ["suspended", "deleted"]

Brackets were chosen because:

  • Unambiguous — no conflict with existing CCL parenthesized grouping
  • Familiar from JSON and most programming languages
  • Clean visual delimiter for the value list

Keyword Aliases

Operator Aliases
IN in, IN
NOT_IN not_in, nin, NOT_IN, notin

No symbol alias is proposed at this time.

Implementation Plan

  1. Add IN and NOT_IN to the operator type — include variadic arity support
  2. Update the CCL parser/grammar — recognize [value, value, ...] as a value list token and associate it with IN/NOT_IN operators
  3. Add keyword aliases for both operators
  4. Write tests — parsing of IN/NOT_IN with bracket syntax, edge cases (single-element list, mixed types, empty list error)

Acceptance Criteria

  • CCL can parse key in [v1, v2, ..., vN] and key not_in [v1, v2, ..., vN]
  • All keyword aliases resolve correctly
  • Variable arity is supported (any number of values >= 1)
  • Parser rejects empty bracket list [] with a clear error
  • Unit tests cover single value, multiple values, mixed types, string values with commas/spaces, and negated form

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions