Add read-only support for PostgreSQL array columns#3402
Add read-only support for PostgreSQL array columns#3402bilby91 wants to merge 3 commits intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds read-only support for PostgreSQL array columns in DAB so schema introspection and runtime initialization no longer fail when encountering int[], text[], boolean[], bigint[], etc. The change threads array-awareness through metadata, GraphQL schema generation, and the EDM model while keeping arrays excluded from mutation inputs.
Changes:
- Detect PostgreSQL array columns during metadata introspection, resolve array element CLR types, and mark array columns read-only.
- Expose array columns as GraphQL list types and represent them as EDM collection properties.
- Add/extend unit + PostgreSQL e2e test coverage plus schema/config updates for a new
array_type_tabletest entity.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Config/DatabasePrimitives/DatabaseObject.cs | Extends ColumnDefinition with IsArrayType/ElementSystemType to carry array metadata. |
| src/Core/Services/MetadataProviders/SqlMetadataProvider.cs | Detects array-typed columns from provider schema and marks them read-only. |
| src/Core/Services/MetadataProviders/PostgreSqlMetadataProvider.cs | Resolves PostgreSQL array element types via information_schema (udt_name) and updates ColumnDefinition. |
| src/Service.GraphQLBuilder/Sql/SchemaConverter.cs | Generates GraphQL fields as ListTypeNode for array columns and adds array-aware system type mapping. |
| src/Core/Parsers/EdmModelBuilder.cs | Emits EDM collection properties for array columns to support OData model building. |
| src/Core/Services/TypeHelper.cs | Adds fallback handling for abstract System.Array in EDM primitive type mapping. |
| src/Service.Tests/GraphQLBuilder/Sql/SchemaConverterTests.cs | Adds unit tests for array→GraphQL list type generation, nullability, directives, and byte[] exclusion. |
| src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/PostgreSqlGQLArrayTypesTests.cs | Adds PostgreSQL e2e GraphQL tests validating array values and null handling. |
| src/Service.Tests/DatabaseSchema-PostgreSql.sql | Adds array_type_table DDL + seed data for PostgreSQL integration tests. |
| src/Service.Tests/dab-config.PostgreSql.json | Adds ArrayType entity configuration (read-only permissions) for PostgreSQL test runs. |
| src/Service.Tests/UnitTests/SerializationDeserializationTests.cs | Updates serialization test expectations to account for added ColumnDefinition fields. |
src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/PostgreSqlGQLArrayTypesTests.cs
Outdated
Show resolved
Hide resolved
src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/PostgreSqlGQLArrayTypesTests.cs
Show resolved
Hide resolved
src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/PostgreSqlGQLArrayTypesTests.cs
Outdated
Show resolved
Hide resolved
5bb9456 to
29833c7
Compare
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
@aaronburtle Thanks for approving CI. I'll take a look at the failing tests and address them. |
|
@aaronburtle I think fixes should be in place. |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
| /// PostgreSQL array types in information_schema use udt_name with a leading underscore | ||
| /// (e.g., _int4 for int[], _text for text[]). | ||
| /// </summary> | ||
| private static readonly Dictionary<string, Type> _pgArrayUdtToElementType = new(StringComparer.OrdinalIgnoreCase) |
There was a problem hiding this comment.
Should be able to add _json, _jsonb, and _money to this dictionary. Currently these types would work for requests, but will generate the wrong schema types
There was a problem hiding this comment.
Make sense. Will verify they work with some new tests.
|
Looks like we are missing tests on the REST side of things. Should add some simple tests to validate REST works with array types, eg. |
| foreach (FieldDefinitionNode field in node.Fields) | ||
| { | ||
| // Skip array/list type fields (e.g., PostgreSQL array columns) - they cannot be ordered. | ||
| if (field.Type.IsListType()) |
There was a problem hiding this comment.
CosmosDB has support for list types, so we can't just broadly skip them here. This needs to be scoped to SQL array columns only without breaking Cosmos list filtering.
There was a problem hiding this comment.
I believe this is why the CosmosDB pipeline is failing.
|
The PG_SQL Integration test failures are from mismatched configs, need to add the new section to |
PostgreSQL array columns (int[], text[], boolean[], bigint[], etc.) were previously unsupported and caused initialization failures. This change adds read-only support so array columns are exposed as list types in GraphQL ([Int], [String], etc.) and as JSON arrays in REST responses. Array columns are marked read-only and excluded from mutation input types until write support is implemented. The implementation adds generic array plumbing in the shared SQL layers and PostgreSQL-specific element type resolution via information_schema udt_name mapping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add ArrayType entity to postgresql-commands.txt so CI's config generator includes it, and skip list-type fields in InputTypeBuilder filter/orderby generation to prevent array columns from being incorrectly processed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add _json, _jsonb, _money to PostgreSQL array type mapping dictionary - Add json[], jsonb[], money[] columns to array_type_table test schema - Add REST integration tests for array type endpoints (list, by PK, nulls) - Update GraphQL array tests to cover new array column types - Update PostgreSQL snapshot to include ArrayType entity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I handle most of the stuff already. Need to replicate the Cosmos issue locally and get it fixed. Will update when I have that aspect ready. |
b9e3435 to
684ced5
Compare
Summary
int[],text[],boolean[],bigint[], etc.) which previously caused initialization failures[Int],[String], etc.) and returned as JSON arrays in REST/MCP responsesChanges
Core plumbing (database-agnostic):
ColumnDefinition: newIsArrayTypeandElementSystemTypepropertiesSqlMetadataProvider: detect array types (System.Array) during schema introspectionSchemaConverter: unwrap array element types and generateListTypeNodefor GraphQL fieldsEdmModelBuilder: represent array columns asEdmCollectionTypeReferencein OData modelTypeHelper: fallback handling for unresolvedSystem.ArraytypePostgreSQL-specific:
PostgreSqlMetadataProvider: overridePopulateColumnDefinitionWithHasDefaultAndDbTypeto resolve element types frominformation_schemaudt_name(_int4→int,_text→string, etc.)Tests:
array_type_tableentityLimitations
$filter: filtering on array columns is not supported (no OData array operators)Test plan