You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that creating a custom enum type and a table that references it in a custom schema (other than public) causes GetSchema to fail with an exception.
To reproduce:
Create a bug schema and run the following within it:
-- Create an enum in `experiment` schemacreatetypebug.colors AS ENUM ('red', 'yellow', 'blue');
-- Create a table in `experiment` schema that references the enumcreatetableperson (
name textnot null,
favorite_color bug.colorsnot null
);
usingconn=newNpgsql.NpgsqlConnection("...");conn.Open();// Next line will fail with "42704: type "colors" does not exist"varcolumns=conn.GetSchema("Columns");
Workaround:
I can workaround the issue by also creating the enum definition in the public schema.
The issue
I think that maybe GetSchema("Columns") is making the assumption that all enums must live in public.
If you are seeing an exception, include the full exceptions details (message and stack trace).
Exception message:
42704: type "colors" does not exist
Stack trace:
at Npgsql.NpgsqlConnector.<<ReadMessage>g__ReadMessageLong|194_0>d.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlDataReader.<Read>d__40.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Npgsql.NpgsqlDataReader.Read()
at Npgsql.NpgsqlDataAdapter.<Fill>d__27.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Npgsql.NpgsqlDataAdapter.<Fill>d__26.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlDataAdapter.<Fill>d__26.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Npgsql.NpgsqlSchema.<GetColumns>d__9.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Npgsql.NpgsqlConnection.GetSchema(String collectionName, String[] restrictions)
at Npgsql.NpgsqlConnection.GetSchema(String collectionName)
at SqlHydra.Npgsql.NpgsqlSchemaProvider.getSchema(Config cfg) in C:\_github\SqlHydra\src\SqlHydra.Npgsql\NpgsqlSchemaProvider.fs:line 14
at Npgsql.Generation.lazySchema@29-2.Invoke(Unit unitVar) in C:\_github\SqlHydra\src\Tests\Npgsql\Generation.fs:line 29
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
Further technical details
Npgsql version: Reproduced in v5.0.7 and v6.0.3
PostgreSQL version:
SELECT version();
PostgreSQL 14.2 (Debian 14.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
Activity
Handle UDTs in non-public schemas in GetSchema
Handle UDTs in non-public schemas in GetSchema (#4394)
Handle UDTs in non-public schemas in GetSchema (#4394)
mukutdanielroy commentedon Jan 15, 2025
did it worked rather than public schema?
Add NpgsqlDataSource constructor to ReplicationConnection classes