Skip to content

Commit

Permalink
Bug with loading data of variation parent if there is no such variation
Browse files Browse the repository at this point in the history
git-svn-id: https://phys12svn.jlab.org/repos/trunk/ccdb@2008 c5ed4466-e916-0410-8347-b3263e9c103d
  • Loading branch information
DmitryRomanovTest committed Jun 16, 2014
1 parent 51de3cd commit fad5eca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 202 deletions.
11 changes: 7 additions & 4 deletions src/Library/Providers/SQLiteDataProvider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1193,18 +1193,21 @@ Assignment* ccdb::SQLiteDataProvider::GetAssignmentShort(int run, const string&
break;
}
} while(result==SQLITE_ROW );

if(assignment == NULL) return NULL;

// finalize the statement to release resources
sqlite3_finalize(mStatement);

//If We have not found data for this variation, getting data for parent variation
if(selectedRows==0 && variation->GetParentDbId()!=0)
if((assignment == NULL && selectedRows==0) && variation->GetParentDbId()!=0)
{
delete table;
return GetAssignmentShort(run, path, time, variation->GetParent()->GetName());
}

if(assignment == NULL)
{
delete table;
return NULL;
}

assignment->SetTypeTable(table);
assignment->BeOwner(table);
Expand Down
19 changes: 11 additions & 8 deletions src/Tests/test_NoMySqlUserAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ TEST_CASE("CCDB/UserAPI/SQLite","tests")
REQUIRE_NOTHROW(result = calib->GetCalib(tabledValues, "test/test_vars/test_table"));
REQUIRE(result);
REQUIRE(tabledValues.size()>0);

//test of getting data as map
//----------------------------------------------------
map<string, string> mappedValues;
REQUIRE_NOTHROW(result = calib->GetCalib(mappedValues, "test/test_vars/test_table"));
REQUIRE(result);
REQUIRE(mappedValues.size()>0);


//test of getting data without / in the beginning
//----------------------------------------------------
vector<map<string, string> > vectorOfMapsdValues;
Expand Down Expand Up @@ -168,6 +161,16 @@ TEST_CASE("CCDB/UserAPI/SQLite_CalibrationGenerator","Use universal generator to
REQUIRE(tabledValues.size()==2);
REQUIRE(tabledValues[0].size()==3);
REQUIRE(tabledValues[0][0]=="10");

//No such calibration exist in test variation, but constants should fallback to default varitaion
res = PathUtils::ParseContext("variation=test");
sqliteCalib = gen->MakeCalibration(TESTS_SQLITE_STRING, 100, res.Variation, res.ConstantsTime);
REQUIRE_NOTHROW(result = sqliteCalib->GetCalib(tabledValues, "/test/test_vars/test_table"));
REQUIRE(result);
REQUIRE(tabledValues.size()>0);
REQUIRE(tabledValues.size()==2);
REQUIRE(tabledValues[0].size()==3);
REQUIRE(tabledValues[0][0]=="2.2");
}

SECTION("Get Assignment test", "Test all elements of getting data through get assignment")
Expand Down
190 changes: 0 additions & 190 deletions src/Tests/test_NoMysqlUserAPI.cc

This file was deleted.

0 comments on commit fad5eca

Please sign in to comment.