IGNITE-2652: CPP: Fixed a bug in QueryFieldsRow::GetNext() method. This closes #483.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8562b001 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8562b001 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8562b001 Branch: refs/heads/ignite-1232 Commit: 8562b001052e398287ef288b4226fa1cf07fcd0e Parents: 933d314 Author: isapego <[email protected]> Authored: Wed Feb 17 12:44:12 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Wed Feb 17 12:44:12 2016 +0300 ---------------------------------------------------------------------- .../cpp/core-test/src/cache_query_test.cpp | 45 ++++++++++++++++++++ .../ignite/cache/query/query_fields_row.h | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8562b001/modules/platforms/cpp/core-test/src/cache_query_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp index 18fe24f..05e6477 100644 --- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp +++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp @@ -713,6 +713,51 @@ BOOST_AUTO_TEST_CASE(TestFieldsQuerySingle) } /** + * Test fields query with single entry. + */ +BOOST_AUTO_TEST_CASE(TestFieldsQueryExceptions) +{ + // Test simple query. + Cache<int, QueryPerson> cache = GetCache(); + + // Test query with two fields of different type. + SqlFieldsQuery qry("select age, name from QueryPerson"); + + QueryFieldsCursor cursor = cache.Query(qry); + CheckEmpty(cursor); + + // Test simple query. + cache.Put(1, QueryPerson("A1", 10)); + + cursor = cache.Query(qry); + + try + { + BOOST_REQUIRE(cursor.HasNext()); + + QueryFieldsRow row = cursor.GetNext(); + + BOOST_REQUIRE(row.HasNext()); + + int age = row.GetNext<int>(); + + BOOST_REQUIRE(age == 10); + + std::string name = row.GetNext<std::string>(); + + BOOST_REQUIRE(name == "A1"); + + BOOST_REQUIRE(!row.HasNext()); + + CheckEmpty(cursor); + } + catch (IgniteError& error) + { + BOOST_FAIL(error.GetText()); + } +} + +/** * Test fields query with two simultaneously handled rows. */ BOOST_AUTO_TEST_CASE(TestFieldsQueryTwo) http://git-wip-us.apache.org/repos/asf/ignite/blob/8562b001/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h index bb10e9e..4f3be4c 100644 --- a/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h +++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_fields_row.h @@ -109,7 +109,7 @@ namespace ignite { IgniteError err; - QueryFieldsRow res = GetNext<T>(err); + T res = GetNext<T>(err); IgniteError::ThrowIfNeeded(err);
