Skip to content

Subqueries returning arrays when they should be returning single values #457

@rswheeldon

Description

@rswheeldon

Describe the bug

If I have a select statement which returns values from subqueries, I'd expect it to return a single value when there's a single matching row and throw an error when there are multiple rows - this is what Postgres does.

To Reproduce

This SQL returns a row with two values in Postgres.

insert into foo(x,y) values (3,4);

select
    (select x from foo),
    (select y from foo);

but in Pg-Mem it returns [3] rather than 3 and [4] rather than 4

In Pg-Mem this SQL returns [3,5], [4,6] where as Postgres throws the error ERROR: more than one row returned by a subquery used as an expression

insert into foo(x,y) values (3,4);
insert into foo(x,y) values (5,6);

select
    (select x from foo),
    (select y from foo);

pg-mem version

2.9.1 (also reproducible on sandbox at time of writing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions