fix optional (#1707)

This commit is contained in:
David Markowitz 2025-01-01 02:07:44 -08:00 committed by GitHub
parent 021db0ecd1
commit 94e7cfc211
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,6 +56,7 @@ std::optional<IProperty::PropertyEntranceResult> MySQLDatabase::GetProperties(co
params.playerId params.playerId
); );
if (count->next()) { if (count->next()) {
if (!result) result = IProperty::PropertyEntranceResult();
result->totalEntriesMatchingQuery = count->getUInt("count"); result->totalEntriesMatchingQuery = count->getUInt("count");
} }
} else { } else {
@ -109,11 +110,13 @@ std::optional<IProperty::PropertyEntranceResult> MySQLDatabase::GetProperties(co
params.playerSort params.playerSort
); );
if (count->next()) { if (count->next()) {
if (!result) result = IProperty::PropertyEntranceResult();
result->totalEntriesMatchingQuery = count->getUInt("count"); result->totalEntriesMatchingQuery = count->getUInt("count");
} }
} }
while (properties->next()) { while (properties->next()) {
if (!result) result = IProperty::PropertyEntranceResult();
auto& entry = result->entries.emplace_back(); auto& entry = result->entries.emplace_back();
entry.id = properties->getUInt64("id"); entry.id = properties->getUInt64("id");
entry.ownerId = properties->getUInt64("owner_id"); entry.ownerId = properties->getUInt64("owner_id");