Skip to content

exists function returns false for null "values" subquery #6960

@philrz

Description

@philrz
$ super -s -c "values exists(values null);"
false

Details

Repro is with super commit 1b7ad2a.

The SQL equivalent returns true, since EXISTS tests whether a subquery/expression produces any row, and a NULL value is still a row (its value being NULL is irrelevant to whether it exists.)

$ psql postgres -c "SELECT EXISTS (SELECT NULL);"
 exists 
--------
 t
(1 row)

Interestingly, using this exact same SQL with super does currently return true.

$ super -version
Version: v0.3.0-129-g1b7ad2acf

$ super -c "SELECT EXISTS (SELECT NULL);"
{"exists(  select \n)":true}

We expect that as users learn SuperSQL they'll evolve/extend their legacy SQL queries into pipe-based equivalents, so this apparent different handling of the null in the values-based equivalent seems like a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions