Skip to content

Support mapping ValueTuple with row constructors  #563

Description

@austindrenski

Could we map otherwise unrecogized instances of ValueTuple to row constructors?

var test = ("red", 4, 2.2);
ctx.SomeEntity.Where(x => (x.Color, x.Price, x.Tax) == test);
SELECT *
FROM "SomeEntity" as x
WHERE ROW(x."Color", x."Price", x."Tax") = @__test_0;

/cc @roji

Related

https://www.postgresql.org/docs/10/static/functions-comparisons.html#ROW-WISE-COMPARISON

Activity

  1. changed the title [-]Mapping ValueTuple with row constructors [/-] [+]Support mapping ValueTuple with row constructors [/+] on Aug 3, 2018
  2. roji commented on Aug 4, 2018

    @roji
    Member

    That's a very cool idea, and it also connects with another idea I had: to map PostgreSQL composites to value tuples. For some reason I got a bit excited for 4.0 and implemented support for mapping composites as dynamic - but doing value tuple seems much more useful/interesting. It may be better to first look at what this means at the Npgsql ADO.NET level, before thinking about it in EF Core.

    If we do end up mapping composites to value tuple, then ROW(...) very neatly fits as the literal SQL representation, which is definitely cool. PostgreSQL also allows you to treat a row of a regular table as a composite type - SELECT * FROM data WHERE data.* = ROW(1,2) - but I can't really see EF Core generating any SQL even close to that. However, composite literals would still be useful for filtering on a composite column of a table, i.e. WHERE my_table.my_column = ROW(1,2).

    So I'd option an issue on https://github.com/npgsql/npgsql/ to track composite mapping to value tuples and concentrate on that first. Once that's done, we can (finally) look at composite support in the EF Core provider (#22), and do the ROW(...) literal representation as part of that. Sounds good?

  3. added this to the Backlog milestone on Aug 12, 2018
  4. added theissue type on Jun 14, 2025
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

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions