Critical: no array / list column type in declarative schema (need text[]) — forces jsonb workarounds

Đang mở
#78 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp, postgresql
Lĩnh vực
databases

Hướng nghiên cứu

Start with migrations/schema.yaml and the DataProviderMigrate entry point, then trace how the existing declarative column types are converted into migration operations. Define how an array type and its element type are represented, and verify that a text[] declaration is migrated in one pass without raw SQL or a separate post-migration step.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

The declarative migration schema (migrations/schema.yaml, applied via DataProviderMigrate) has no array / list column type. There is no way to declare a Postgres text[] (or any T[]) column. This forces a jsonb workaround for every naturally-array-shaped column, which loses array typing, element constraints, and the ability to use Postgres array operators / GIN indexing.

Severity: critical for any schema that needs first-class array columns — it changes the data model (jsonb instead of text[]) and pushes validation that the DB could enforce up into application code.

Where this bit us (real case)

NAP's BYO-IdP end-user auth needs a per-tenant allow-list of permitted JWT signing algorithms — naturally a text[]. There is no array type, so we modelled it as Json (jsonb):

# migrations/schema.yaml
- name: allowed_algs
  type: Json                 # WANTED: a text[] / array type
  isNullable: false
  defaultValue: "'[]'::jsonb"

We could only make this safe because no RLS predicate parses the column — the verifier reads it in Python. If we had needed a DB-side constraint or an array containment check in a policy ('RS256' = ANY(allowed_algs)), jsonb would not have been sufficient and we'd have been stuck.

Types currently available

From a real production schema, the declarative types in use are: BigInt, Boolean, Date, DateTimeOffset, Decimal, Int, Json, Text, Uuid. None expresses an array.

Requested fix

Add a declarative array column type so text[] (and ideally uuid[], int[], etc.) can be expressed without dropping to jsonb. Strawman shape:

- name: allowed_algs
  type: Array
  elementType: Text
  isNullable: false
  defaultValue: "'{}'"

or an inline form such as type: "Text[]". Either is fine — the requirement is simply: a first-class array column type in the declarative schema, migrated the same one-pass way as every other column (no raw SQL / no separate post-migration step, since the consumer's hard rule is "no SQL/DDL in schema.yaml").

Why not just keep using jsonb

  • jsonb arrays can't be used with native array operators (= ANY(...), @> on typed arrays) the way text[] can, including inside RLS policies.
  • jsonb loses element typing — ["RS256", 7, null] is a valid jsonb array; text[] rejects it.
  • It's a silent modelling compromise on every array-shaped column, not a one-off.

Context

Related docs gap: #72 (the documented column-type list is already known to be incomplete). This issue is about the missing capability, not just the docs.

Ngôn ngữ chính
C#
Star
68
Fork
4
Merge trung bình
50 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Nimblesite/DataProvider

Tất cả issue của Nimblesite/DataProvider

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.