Browse Source

Fix database creating/loading methods

Methods didn't do `none` checks where necessary and passed `MutableText`
as a key, where `Text` keys were expected.
pull/8/head
Anton Tarasenko 3 years ago
parent
commit
68bd7265f8
  1. 11
      sources/Data/Database/DBAPI.uc

11
sources/Data/Database/DBAPI.uc

@ -51,6 +51,7 @@ public final function Database Load(Text databaseLink)
{ {
local Parser parser; local Parser parser;
local Database result; local Database result;
local Text immutableDatabaseName;
local MutableText databaseName; local MutableText databaseName;
if (databaseLink == none) { if (databaseLink == none) {
return none; return none;
@ -65,9 +66,11 @@ public final function Database Load(Text databaseLink)
parser.FreeSelf(); parser.FreeSelf();
return none; return none;
} }
result = LoadLocal(databaseName); immutableDatabaseName = databaseName.Copy();
result = LoadLocal(immutableDatabaseName);
parser.FreeSelf(); parser.FreeSelf();
databaseName.FreeSelf(); databaseName.FreeSelf();
immutableDatabaseName.FreeSelf();
return result; return result;
} }
@ -156,6 +159,9 @@ public final function LocalDatabaseInstance LoadLocal(Text databaseName)
local Text rootRecordName; local Text rootRecordName;
local LocalDatabase newConfig; local LocalDatabase newConfig;
local LocalDatabaseInstance newLocalDBInstance; local LocalDatabaseInstance newLocalDBInstance;
if (databaseName == none) {
return none;
}
CreateLocalDBMapIfMissing(); CreateLocalDBMapIfMissing();
if (loadedLocalDatabases.HasKey(databaseName)) if (loadedLocalDatabases.HasKey(databaseName))
{ {
@ -214,6 +220,9 @@ public final function bool DeleteLocal(Text databaseName)
local LocalDatabase localDatabaseConfig; local LocalDatabase localDatabaseConfig;
local LocalDatabaseInstance localDatabase; local LocalDatabaseInstance localDatabase;
local AssociativeArray.Entry dbEntry; local AssociativeArray.Entry dbEntry;
if (databaseName == none) {
return false;
}
CreateLocalDBMapIfMissing(); CreateLocalDBMapIfMissing();
// To delete database we first need to load it // To delete database we first need to load it
localDatabase = LoadLocal(databaseName); localDatabase = LoadLocal(databaseName);

Loading…
Cancel
Save