diff --git a/sources/Data/Database/DBTask.uc b/sources/Data/Database/DBTask.uc index ce7abec..40e947c 100644 --- a/sources/Data/Database/DBTask.uc +++ b/sources/Data/Database/DBTask.uc @@ -118,14 +118,17 @@ public final function SetResult(Database.DBQueryResult result) * Since this base class does not itself have `connect()` delegate declared - * this method cannot be implemented here. */ -protected function CompleteSelf() {} +protected function CompleteSelf(Database source) {} /** * Attempts to complete this task. * Can only succeed iff caller task both has necessary data to complete it's * query and all previous tasks have completed. + * + * @param source Database that will be passed to `DBTask`'s delegate as + * its cause. */ -public final function TryCompleting() +public final function TryCompleting(optional Database source) { local int i; local array tasksQueue; @@ -136,7 +139,7 @@ public final function TryCompleting() { if (tasksQueue[i].isReadyToComplete) { - tasksQueue[i].CompleteSelf(); + tasksQueue[i].CompleteSelf(source); _.memory.Free(tasksQueue[i]); } else { diff --git a/sources/Data/Database/Tasks/DBCheckTask.uc b/sources/Data/Database/Tasks/DBCheckTask.uc index a5af3e0..694343a 100644 --- a/sources/Data/Database/Tasks/DBCheckTask.uc +++ b/sources/Data/Database/Tasks/DBCheckTask.uc @@ -21,7 +21,10 @@ class DBCheckTask extends DBTask; var private Database.DataType queryTypeResponse; -delegate connect(Database.DBQueryResult result, Database.DataType type) {} +delegate connect( + Database.DBQueryResult result, + Database.DataType type, + Database source) {} protected function Finalizer() { @@ -35,9 +38,9 @@ public function SetDataType(Database.DataType type) queryTypeResponse = type; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult(), queryTypeResponse); + connect(GetResult(), queryTypeResponse, source); } defaultproperties diff --git a/sources/Data/Database/Tasks/DBIncrementTask.uc b/sources/Data/Database/Tasks/DBIncrementTask.uc index 9507ff0..886c739 100644 --- a/sources/Data/Database/Tasks/DBIncrementTask.uc +++ b/sources/Data/Database/Tasks/DBIncrementTask.uc @@ -19,7 +19,7 @@ */ class DBIncrementTask extends DBTask; -delegate connect(Database.DBQueryResult result) {} +delegate connect(Database.DBQueryResult result, Database source) {} protected function Finalizer() { @@ -27,9 +27,9 @@ protected function Finalizer() connect = none; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult()); + connect(GetResult(), source); } defaultproperties diff --git a/sources/Data/Database/Tasks/DBKeysTask.uc b/sources/Data/Database/Tasks/DBKeysTask.uc index e7b2d37..2c25057 100644 --- a/sources/Data/Database/Tasks/DBKeysTask.uc +++ b/sources/Data/Database/Tasks/DBKeysTask.uc @@ -21,7 +21,10 @@ class DBKeysTask extends DBTask; var private DynamicArray queryKeysResponse; -delegate connect(Database.DBQueryResult result, DynamicArray keys) {} +delegate connect( + Database.DBQueryResult result, + DynamicArray keys, + Database source) {} protected function Finalizer() { @@ -35,9 +38,9 @@ public function SetDataKeys(DynamicArray keys) queryKeysResponse = keys; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult(), queryKeysResponse); + connect(GetResult(), queryKeysResponse, source); } defaultproperties diff --git a/sources/Data/Database/Tasks/DBReadTask.uc b/sources/Data/Database/Tasks/DBReadTask.uc index b51de6a..54b4925 100644 --- a/sources/Data/Database/Tasks/DBReadTask.uc +++ b/sources/Data/Database/Tasks/DBReadTask.uc @@ -21,7 +21,10 @@ class DBReadTask extends DBTask; var private AcediaObject queryDataResponse; -delegate connect(Database.DBQueryResult result, AcediaObject data) {} +delegate connect( + Database.DBQueryResult result, + AcediaObject data, + Database source) {} protected function Finalizer() { @@ -35,9 +38,9 @@ public function SetReadData(AcediaObject data) queryDataResponse = data; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult(), queryDataResponse); + connect(GetResult(), queryDataResponse, source); } defaultproperties diff --git a/sources/Data/Database/Tasks/DBRemoveTask.uc b/sources/Data/Database/Tasks/DBRemoveTask.uc index 88cc4aa..50278f7 100644 --- a/sources/Data/Database/Tasks/DBRemoveTask.uc +++ b/sources/Data/Database/Tasks/DBRemoveTask.uc @@ -19,7 +19,7 @@ */ class DBRemoveTask extends DBTask; -delegate connect(Database.DBQueryResult result) {} +delegate connect(Database.DBQueryResult result, Database source) {} protected function Finalizer() { @@ -27,9 +27,9 @@ protected function Finalizer() connect = none; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult()); + connect(GetResult(), source); } defaultproperties diff --git a/sources/Data/Database/Tasks/DBSizeTask.uc b/sources/Data/Database/Tasks/DBSizeTask.uc index 8d31d1a..564ac9e 100644 --- a/sources/Data/Database/Tasks/DBSizeTask.uc +++ b/sources/Data/Database/Tasks/DBSizeTask.uc @@ -21,7 +21,7 @@ class DBSizeTask extends DBTask; var private int querySizeResponse; -delegate connect(Database.DBQueryResult result, int size) {} +delegate connect(Database.DBQueryResult result, int size, Database source) {} protected function Finalizer() { @@ -35,9 +35,9 @@ public function SetDataSize(int size) querySizeResponse = size; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult(), querySizeResponse); + connect(GetResult(), querySizeResponse, source); } defaultproperties diff --git a/sources/Data/Database/Tasks/DBWriteTask.uc b/sources/Data/Database/Tasks/DBWriteTask.uc index 7e499ba..5c3961d 100644 --- a/sources/Data/Database/Tasks/DBWriteTask.uc +++ b/sources/Data/Database/Tasks/DBWriteTask.uc @@ -19,7 +19,7 @@ */ class DBWriteTask extends DBTask; -delegate connect(Database.DBQueryResult result) {} +delegate connect(Database.DBQueryResult result, Database source) {} protected function Finalizer() { @@ -27,9 +27,9 @@ protected function Finalizer() connect = none; } -protected function CompleteSelf() +protected function CompleteSelf(Database source) { - connect(GetResult()); + connect(GetResult(), source); } defaultproperties diff --git a/sources/Data/Database/Tests/TEST_LocalDatabase.uc b/sources/Data/Database/Tests/TEST_LocalDatabase.uc index d2e33e3..5ea4204 100644 --- a/sources/Data/Database/Tests/TEST_LocalDatabase.uc +++ b/sources/Data/Database/Tests/TEST_LocalDatabase.uc @@ -29,8 +29,9 @@ var protected AssociativeArray resultData; var protected AcediaObject resultObject; protected function DBReadingHandler( - Database.DBQueryResult result, - AcediaObject data) + Database.DBQueryResult result, + AcediaObject data, + Database source) { default.resultType = result; default.resultObject = data; @@ -38,40 +39,49 @@ protected function DBReadingHandler( } protected function DBKeysHandler( - Database.DBQueryResult result, - DynamicArray keys) + Database.DBQueryResult result, + DynamicArray keys, + Database source) { default.resultType = result; default.resultKeys = keys; } protected function DBCheckHandler( - Database.DBQueryResult result, - Database.DataType type) + Database.DBQueryResult result, + Database.DataType type, + Database source) { default.resultType = result; default.resultDataType = type; } protected function DBSizeHandler( - Database.DBQueryResult result, - int size) + Database.DBQueryResult result, + int size, + Database source) { default.resultType = result; default.resultSize = size; } -protected function DBWritingHandler(Database.DBQueryResult result) +protected function DBWritingHandler( + Database.DBQueryResult result, + Database source) { default.resultType = result; } -protected function DBIncrementHandler(Database.DBQueryResult result) +protected function DBIncrementHandler( + Database.DBQueryResult result, + Database source) { default.resultType = result; } -protected function DBRemoveHandler(Database.DBQueryResult result) +protected function DBRemoveHandler( + Database.DBQueryResult result, + Database source) { default.resultType = result; }