From cd1e73d4c6968a80306ba21b6b22d6a02a3104c3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 13 Dec 2014 21:49:02 +0100 Subject: [PATCH] Fix for geo lookup: need exact match --- Database/Database-Geographies.cs | 3 +-- Logic/Cache/GeographyCache.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Database/Database-Geographies.cs b/Database/Database-Geographies.cs index 18055d56..723f08f6 100644 --- a/Database/Database-Geographies.cs +++ b/Database/Database-Geographies.cs @@ -284,8 +284,7 @@ namespace Swarmops.Database DbCommand command = GetDbCommand ( - "SELECT " + geographyFieldSequence + " WHERE Name like '" + geographyName.Replace ("'", "''") + - "%'", + "SELECT " + geographyFieldSequence + " WHERE Name ='" + geographyName.Replace ("'", "''") + "'", connection); using (DbDataReader reader = command.ExecuteReader()) diff --git a/Logic/Cache/GeographyCache.cs b/Logic/Cache/GeographyCache.cs index 87023b88..19128a60 100644 --- a/Logic/Cache/GeographyCache.cs +++ b/Logic/Cache/GeographyCache.cs @@ -228,7 +228,7 @@ namespace Swarmops.Logic.Cache Dictionary> hashedGeographies = GetHashedGeographies(); foreach (int entry in hashedGeographies.Keys) { - if (hashedGeographies[entry][0].Name.ToLower().Trim().StartsWith (cmpName)) + if (hashedGeographies[entry][0].Name.ToLower().Trim() == cmpName) return hashedGeographies[entry][0]; } //TODO: This can miss due to that the geography was added after last cache reload