Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/NSchema.Postgres/NSchema.Postgres.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>5.0.0-alpha.6</Version>
<Version>5.0.0-alpha.7</Version>
<AssemblyVersion>$(Version.Split('-')[0])</AssemblyVersion>
<FileVersion>$(Version.Split('-')[0])</FileVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
5 changes: 3 additions & 2 deletions src/NSchema.Postgres/Sql/PostgresDatabaseIntrospector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down