Normally i would expect this behaviour, your right..
So lets have a closer look... The void gets fired and the SQL Query will be setup, it will look like this:
INSERT DELAYED INTO `anope_server` (name, hops, comment, link_time, online, ulined) "
"VALUES ('Testserver.Inter.NET', 0, 'No Comment', '2020-10-21 07:00:00', 'Y', 'N') "
"ON DUPLICATE KEY UPDATE name='Testserver.Inter.NET', hops=0, comment='No Comment', "
"link_time='2020-10-21 07:00:00', online=VALUES(online), ulined='N'";
On the first execution, it will add a new entry into the table and say the Server is online=Y...
But on the further executions, as we have now a duplicate key, the second statement of the query will get handled, 'online' will stay at its default value of 'N' as online never gets parsed (also link_time) so the default value for that column is assumed
So from my point of view, this should fix that issue:
void IRC2SQL::OnNewServer(Server *server)
{
query = "INSERT DELAYED INTO `" + prefix + "server` (name, hops, comment, link_time, online, ulined) "
"VALUES (@name@, @hops@, @comment@, now(), 'Y', @ulined@) "
"ON DUPLICATE KEY UPDATE name=VALUES(name), hops=VALUES(hops), comment=VALUES(comment), "
"link_time=NOW(), online='Y', ulined=(ulined)";
query.SetValue("name", server->GetName());
query.SetValue("hops", server->GetHops());
query.SetValue("comment", server->GetDescription());
query.SetValue("ulined", server->IsULined() ? "Y" : "N");
this->RunQuery(query);
}
Im not 100% sure about the link_time, but online=Y makes definitly sense at that point... The VOID will get fired when a Server connects to the network, so it IS online