Skip to content

Support NULL elements in PostgreSQL arrays #55

Description

@alexeichhorn

Problem

dbkit supports:

Vec<String>         // required TEXT[] value with non-null elements
Option<Vec<String>> // nullable TEXT[] value with non-null elements

It does not support PostgreSQL arrays containing nullable elements:

Vec<Option<String>>
Option<Vec<Option<String>>>

Using Vec<Option<String>> in a #[model] currently fails during macro expansion because dbkit::Value only supports Vec<String>. Conversely, reading a valid PostgreSQL value such as ARRAY['one', NULL, 'three'] into Vec<String> fails during decoding.

Expected behavior

  • Support Vec<Option<String>> for a present TEXT[] containing nullable elements.
  • Support Option<Vec<Option<String>>> so container and element nullability compose.
  • Preserve existing Vec<String> and Option<Vec<String>> behavior.
  • Cover insertion, updates, selection, and binding where arrays are currently supported.
  • Test empty arrays, mixed values/NULLs, all-NULL elements, and a NULL array.

This can start with the existing TEXT[] support; it does not need to generalize every PostgreSQL array element type at the same time.

PostgreSQL array NULL elements

Activity

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions