Skip to content

Commit 86656ec

Browse files
author
giordanol
committed
Use double quote
1 parent 71c1f14 commit 86656ec

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Blumchen/Subscriptions/Management/PublicationManagement.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,11 @@ internal static Task CreatePublication(
6969
ISet<string> eventTypes,
7070
CancellationToken ct
7171
) {
72+
var sql = $"CREATE PUBLICATION \"{publicationName}\" FOR TABLE {tableName} {{0}} WITH (publish = 'insert');";
7273
return eventTypes.Count switch
7374
{
74-
0 => Execute(dataSource, $"CREATE PUBLICATION {publicationName} FOR TABLE {tableName} WITH (publish = 'insert');",
75-
ct
76-
),
77-
_ => Execute(dataSource, $"CREATE PUBLICATION {publicationName} FOR TABLE {tableName} WHERE ({PublicationFilter(eventTypes)}) WITH (publish = 'insert');",
78-
ct
79-
)
75+
0 => Execute(dataSource, string.Format(sql,string.Empty), ct),
76+
_ => Execute(dataSource, string.Format(sql, $"WHERE ({PublicationFilter(eventTypes)})"), ct)
8077
};
8178
static string PublicationFilter(ICollection<string> input) => string.Join(" OR ", input.Select(s => $"message_type = '{s}'"));
8279
}
@@ -128,8 +125,7 @@ private static Task<bool> PublicationExists(
128125
this NpgsqlDataSource dataSource,
129126
string publicationName,
130127
CancellationToken ct
131-
) =>
132-
dataSource.Exists("pg_publication", "pubname = $1", [publicationName], ct);
128+
) => dataSource.Exists("pg_publication", "pubname = $1", [publicationName], ct);
133129

134130
public abstract record SetupPublicationResult
135131
{

0 commit comments

Comments
 (0)