Keep N1MM's message columns when the contest definition is saved again
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,12 +33,23 @@ public sealed class SqliteLogStore : LogStore
|
||||
{
|
||||
using SqliteCommand command = connection.CreateCommand();
|
||||
command.CommandText = """
|
||||
INSERT OR REPLACE INTO Contest
|
||||
INSERT INTO Contest
|
||||
(Name, DisplayName, CabrilloName, Mode, DupeType, Multiplier1Name,
|
||||
Multiplier2Name, Multiplier3Name, Period, PointsPerContact, CabrilloVersion)
|
||||
VALUES
|
||||
(@name, @display, @cabrillo, @mode, @dupe, @mult1, @mult2, @mult3,
|
||||
@period, @points, @version)
|
||||
ON CONFLICT(Name) DO UPDATE SET
|
||||
DisplayName = excluded.DisplayName,
|
||||
CabrilloName = excluded.CabrilloName,
|
||||
Mode = excluded.Mode,
|
||||
DupeType = excluded.DupeType,
|
||||
Multiplier1Name = excluded.Multiplier1Name,
|
||||
Multiplier2Name = excluded.Multiplier2Name,
|
||||
Multiplier3Name = excluded.Multiplier3Name,
|
||||
Period = excluded.Period,
|
||||
PointsPerContact = excluded.PointsPerContact,
|
||||
CabrilloVersion = excluded.CabrilloVersion
|
||||
""";
|
||||
command.Parameters.AddWithValue("@name", definition.Name);
|
||||
command.Parameters.AddWithValue("@display", definition.DisplayName);
|
||||
|
||||
@@ -195,4 +195,40 @@ public class SqliteLogStoreTests : IDisposable
|
||||
command.CommandText = sql;
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SavingADefinitionAgainKeepsTheMessagesN1mmStored()
|
||||
{
|
||||
ContestDefinition definition = new()
|
||||
{
|
||||
Name = "CQWWCW",
|
||||
DisplayName = "CQ WorldWide CW",
|
||||
CabrilloName = "CQ-WW-CW",
|
||||
Mode = "CW",
|
||||
};
|
||||
using (SqliteLogStore store = SqliteLogStore.Open(path))
|
||||
{
|
||||
store.SaveContestDefinition(definition);
|
||||
}
|
||||
using (SqliteConnection connection = new($"Data Source={path}"))
|
||||
{
|
||||
connection.Open();
|
||||
using SqliteCommand set = connection.CreateCommand();
|
||||
set.CommandText = "UPDATE Contest SET CWMessages = 'F1;CQ' WHERE Name = 'CQWWCW'";
|
||||
set.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
using (SqliteLogStore store = SqliteLogStore.Open(path))
|
||||
{
|
||||
store.SaveContestDefinition(definition with { DisplayName = "Renamed" });
|
||||
}
|
||||
|
||||
using SqliteConnection check = new($"Data Source={path}");
|
||||
check.Open();
|
||||
using SqliteCommand read = check.CreateCommand();
|
||||
read.CommandText = "SELECT DisplayName, CWMessages FROM Contest WHERE Name = 'CQWWCW'";
|
||||
using SqliteDataReader row = read.ExecuteReader();
|
||||
Assert.True(row.Read());
|
||||
Assert.Equal(("Renamed", "F1;CQ"), (row.GetString(0), row.GetString(1)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user