From 968e07c9721297e8b530882da66fa0e47be417a4 Mon Sep 17 00:00:00 2001 From: Tom Wolfe Date: Fri, 24 Jul 2026 16:24:15 +0100 Subject: [PATCH 1/2] fix: don't fully-qualify pg_catalog types. --- .../Sql/PostgresDatabaseIntrospector.cs | 5 +++-- .../Sql/PostgresDatabaseIntrospectorTests.cs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/NSchema.Postgres/Sql/PostgresDatabaseIntrospector.cs b/src/NSchema.Postgres/Sql/PostgresDatabaseIntrospector.cs index 2ca17c8..6640369 100644 --- a/src/NSchema.Postgres/Sql/PostgresDatabaseIntrospector.cs +++ b/src/NSchema.Postgres/Sql/PostgresDatabaseIntrospector.cs @@ -1831,8 +1831,9 @@ private static SqlType MapSqlType(string dataType, string udtName, string? udtSc "uuid" => SqlType.Guid, "bytea" => SqlType.VarBinary(), // A user-defined type (enum, composite, …): preserve its schema so the type round-trips, collapsing - // the default schema the same way a domain does. - _ => udtSchema is null or "public" ? SqlType.Custom(udtName) : SqlType.Custom(udtSchema, udtName), + // the default schema the same way a domain does. Built-ins outside the switch (jsonb, inet, …) + // also land here with udt_schema = pg_catalog, so collapse that too. + _ => udtSchema is null or "public" or "pg_catalog" ? SqlType.Custom(udtName) : SqlType.Custom(udtSchema, udtName), }; } diff --git a/tests/NSchema.Postgres.Tests/Sql/PostgresDatabaseIntrospectorTests.cs b/tests/NSchema.Postgres.Tests/Sql/PostgresDatabaseIntrospectorTests.cs index 68811f2..5bfd766 100644 --- a/tests/NSchema.Postgres.Tests/Sql/PostgresDatabaseIntrospectorTests.cs +++ b/tests/NSchema.Postgres.Tests/Sql/PostgresDatabaseIntrospectorTests.cs @@ -820,6 +820,21 @@ await Exec($""" column.Type.ShouldBe(SqlType.Custom(_schema, "order_status")); } + [Fact] + public async Task GetDatabase_BuiltInFallthroughColumn_MappedUnqualified() + { + // Arrange — jsonb also hits MapSqlType's fall-through, but its pg_catalog udt_schema + // must collapse so the type reads as declared. + await Exec($"""CREATE TABLE "{_schema}".events (payload jsonb NOT NULL);"""); + + // Act + var column = (await Introspect(_schema)) + .Schemas[0].Tables.ShouldHaveSingleItem().Columns.ShouldHaveSingleItem(); + + // Assert + column.Type.ShouldBe(SqlType.Custom("jsonb")); + } + // ── Sequences ───────────────────────────────────────────────────────────── [Fact] From 62c45a6b9f98915594805b6fe98fedebc4825a77 Mon Sep 17 00:00:00 2001 From: Tom Wolfe Date: Fri, 24 Jul 2026 16:24:28 +0100 Subject: [PATCH 2/2] build: bump version. --- src/NSchema.Postgres/NSchema.Postgres.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NSchema.Postgres/NSchema.Postgres.csproj b/src/NSchema.Postgres/NSchema.Postgres.csproj index 339ed5d..c8ed1c2 100644 --- a/src/NSchema.Postgres/NSchema.Postgres.csproj +++ b/src/NSchema.Postgres/NSchema.Postgres.csproj @@ -20,7 +20,7 @@ true true snupkg - 5.0.0-alpha.6 + 5.0.0-alpha.7 $(Version.Split('-')[0]) $(Version.Split('-')[0]) true