Skip to content

Support primitive collections as JSON (instead of an array) #3122

Closed

Description

@roji

The default - and natural - way to map a primitive collection (e.g. int[]) in PostgreSQL is to a database array (the PG integer[]) type. This is PG-unique feature; in other database, primitive collections are mapped to a JSON text column in the database.

However, in some cases it may still make sense to map primitive collections to JSON in PG, just like we do in other databases. While we seem to support the mapping itself, most forms of querying won't work (e.g. we need to translate to jsonb_to_recordset instead of unnest).

Since mapping to PG arrays is the recommended way, this isn't likely to be high priority. Putting this in the backlog to gather user feedback.

Note: one reason to do this would be to allow nested collections (once EF itself supports these in relational). PostgreSQL doesn't support arrays of arrays, so it's impossible to support nested collections when mapping to arrays; but JSON would work. Think about whether this should be automatic, or require some sort of opt in to make it clear that it's JSON rather than arrays.

Activity

  1. added this to the Backlog milestone on Mar 4, 2024
  2. roderickgreen commented on Apr 23, 2025

    @roderickgreen
  3. roji commented on Apr 23, 2025

    @roji
    Author
  4. roderickgreen commented on Apr 24, 2025

    @roderickgreen
  5. added theissue type on Jun 14, 2025
  6. modified the milestones: Backlog, 10.0.0 on Sep 22, 2025
  7. self-assigned this
    on Sep 22, 2025
  8. added 2 commits that reference this issue on Sep 22, 2025
    25f5469
    831a567
  9. added a commit that references this issue on Sep 26, 2025
    4405acb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions