When trying to use the Postgres event store along with npgsql >= 7.0.0 it breaks with the following exception:
Npgsql.PostgresException (0x80004005): 42883: procedure eventuous.read_all_forwards(_from_position => bigint, _count => integer) does not exist
The workaround is to put the following code somewhere (I put it above the services.AddAggregateStore<PostgresStore>();):
AppContext.SetSwitch("Npgsql.EnableStoredProcedureCompatMode", true);
The real solution would probably be something like rewriting this (and other similar methods):
|
protected override NpgsqlCommand PrepareCommand(NpgsqlConnection connection, long start) { |
|
var cmd = new NpgsqlCommand(Schema.ReadAllForwards, connection); |
|
|
|
cmd.CommandType = CommandType.StoredProcedure; |
|
cmd.Parameters.AddWithValue("_from_position", NpgsqlDbType.Bigint, start + 1); |
|
cmd.Parameters.AddWithValue("_count", NpgsqlDbType.Integer, Options.MaxPageSize); |
|
return cmd; |
|
} |
into just using the recommended plain method which is
SELECT * FROM function_name($1,$2)
Source: https://www.npgsql.org/doc/release-notes/7.0.html#a-namecommandtypestoredprocedure-commandtypestoredprocedure-now-invokes-procedures-instead-of-functions
Another issue is that connections to the database are not reused/not closed which is probably related to the new DbDataSource way of connecting: https://www.npgsql.org/doc/release-notes/7.0.html#dbdatasource
When trying to use the Postgres event store along with npgsql >= 7.0.0 it breaks with the following exception:
The workaround is to put the following code somewhere (I put it above the
services.AddAggregateStore<PostgresStore>();):The real solution would probably be something like rewriting this (and other similar methods):
eventuous/src/Postgres/src/Eventuous.Postgresql/Subscriptions/PostgresAllStreamSubscription.cs
Lines 24 to 31 in b4f1af7
into just using the recommended plain method which is
SELECT * FROM function_name($1,$2)Source: https://www.npgsql.org/doc/release-notes/7.0.html#a-namecommandtypestoredprocedure-commandtypestoredprocedure-now-invokes-procedures-instead-of-functions
Another issue is that connections to the database are not reused/not closed which is probably related to the new
DbDataSourceway of connecting: https://www.npgsql.org/doc/release-notes/7.0.html#dbdatasource