Skip to content

Commit

Permalink
Use double quote
Browse files Browse the repository at this point in the history
  • Loading branch information
lsfera committed Jul 4, 2024
1 parent 71c1f14 commit 86656ec
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Blumchen/Subscriptions/Management/PublicationManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ internal static Task CreatePublication(
ISet<string> eventTypes,
CancellationToken ct
) {
var sql = $"CREATE PUBLICATION \"{publicationName}\" FOR TABLE {tableName} {{0}} WITH (publish = 'insert');";
return eventTypes.Count switch
{
0 => Execute(dataSource, $"CREATE PUBLICATION {publicationName} FOR TABLE {tableName} WITH (publish = 'insert');",
ct
),
_ => Execute(dataSource, $"CREATE PUBLICATION {publicationName} FOR TABLE {tableName} WHERE ({PublicationFilter(eventTypes)}) WITH (publish = 'insert');",
ct
)
0 => Execute(dataSource, string.Format(sql,string.Empty), ct),
_ => Execute(dataSource, string.Format(sql, $"WHERE ({PublicationFilter(eventTypes)})"), ct)
};
static string PublicationFilter(ICollection<string> input) => string.Join(" OR ", input.Select(s => $"message_type = '{s}'"));
}
Expand Down Expand Up @@ -128,8 +125,7 @@ private static Task<bool> PublicationExists(
this NpgsqlDataSource dataSource,
string publicationName,
CancellationToken ct
) =>
dataSource.Exists("pg_publication", "pubname = $1", [publicationName], ct);
) => dataSource.Exists("pg_publication", "pubname = $1", [publicationName], ct);

public abstract record SetupPublicationResult
{
Expand Down

0 comments on commit 86656ec

Please sign in to comment.