Skip to content

IN (5, 6) and IN ('5', '6') share one cached set, so the result depends on which query ran first #2912

Closed

Description

@mathiasrw

An IN list is turned into a Set once and cached in alasql.sets, keyed by the values joined with commas. The key does not tell numbers from strings, so IN (5, 6) and IN ('5', '6') share one cached set, and the second query uses the values of whichever ran first.

var data = [{a: 5}, {a: '5'}, {a: 6}];
alasql('SELECT VALUE COUNT(*) FROM ? WHERE a IN (5, 6)', [data]); // 2, right
alasql("SELECT VALUE COUNT(*) FROM ? WHERE a IN ('5', '6')", [data]); // 2, should be 1

Run the string query first and it gives 1, and then the number query gives 1 instead of 2. The same goes for NOT IN. Measured on develop and 4.21.0.

A key that keeps the type of each value, like JSON.stringify of the list, fixes it.

Activity

  1. added this to the v4.x Focus milestone on Oct 28, 2026
  2. added a commit that references this issue on Oct 28, 2026
    9932ac9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions