Skip to content

A constant IN list returns the answer of an earlier list with the same text: 1 IN (1) is false after '1' IN ('1') #2753

Open

Description

@mathiasrw

A constant IN (...) list can return the answer of an earlier query whose list has the same text. Seen in the sqllogictest run (evidence/in1.test) and reproduced on develop (06211a0):

alasql("SELECT VALUE '1' IN ('1')");      // true
alasql('SELECT VALUE 1 IN (1)');          // false, expected true

alasql("SELECT VALUE 'a,b' IN ('a,b')");  // true
alasql("SELECT VALUE 'a' IN ('a','b')");  // false, expected true
alasql("SELECT VALUE 'a,b' IN ('a','b')");// true, expected false

alasql("SELECT VALUE 'a' IN ('a')");      // true
alasql("SELECT VALUE 'a' IN (a)");        // false: the column a is not read

Each query alone gives the right answer. NOT IN behaves the same way.

Context

With the statement cache on, Op.toJS in src/50expression.js (the IN and NOT IN branches) keeps the Set of a constant list in alasql.sets, keyed by allValues.join(','). The key loses the type ('1' and 1 both give 1) and the boundaries between values ('a,b' and 'a','b' both give a,b). The list values are taken as value.value, which is undefined for a column, so a column in the list is not read.

A wrong result that depends on what ran before, so not breaking.

Activity

  1. added this to the v4.x Focus milestone on Oct 21, 2026
  2. mateuscmtropical commented on Nov 11, 2026

    @mateuscmtropical
    Contributor

    Hi, I'd like to work on this one.

  3. mateuscmtropical commented on Nov 11, 2026

    @mateuscmtropical
    Contributor

    Hi, I've opened a PR for this: #3044

  4. modified the milestones: v4.x Focus, v5.0.0 on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions