From 555b242317c770136d93a0ccc95335d4e1146781 Mon Sep 17 00:00:00 2001 From: isapego Date: Mon, 15 Feb 2016 16:09:53 +0300 Subject: [PATCH] IGNITE-2652: Fix for the QueryFieldsRow::GetNext. --- .../cpp/core-test/src/cache_query_test.cpp | 45 +++++++++++++++++++ .../ignite/cache/query/query_fields_row.h | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) 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 18fe24f976fcf..05e6477ea037e 100644 --- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp +++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp @@ -712,6 +712,51 @@ BOOST_AUTO_TEST_CASE(TestFieldsQuerySingle) CheckEmpty(cursor); } +/** + * Test fields query with single entry. + */ +BOOST_AUTO_TEST_CASE(TestFieldsQueryExceptions) +{ + // Test simple query. + Cache 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(); + + BOOST_REQUIRE(age == 10); + + std::string name = row.GetNext(); + + 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. */ 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 bb10e9eb8d246..4f3be4cf862ed 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(err); + T res = GetNext(err); IgniteError::ThrowIfNeeded(err);