Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-9174: fix displaying the result of a gfsh query containing a UUID #6365

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.UUID;

import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -175,6 +176,21 @@ public void testSimpleQueryOnLocator() {
});
}

@Test
public void testSimpleQueryWithUUID() {
server1.invoke(() -> prepareDataForRegionWithUUID(DATA_PAR_REGION_NAME_PATH));
String uuidKey = String.valueOf(new UUID(1, 1));
String query = "query --query=\"select key from " + DATA_PAR_REGION_NAME_PATH
+ ".entries\"";
String query1 = "query --query=\"select key,value from " + DATA_PAR_REGION_NAME_PATH
+ ".entries\"";

gfsh.executeAndAssertThat(query).statusIsSuccess()
.containsOutput(uuidKey);
gfsh.executeAndAssertThat(query1).statusIsSuccess()
.containsOutput(uuidKey, "value");
}

@Test
public void testQueryEvictedDataDeserializable() {
server1.invoke(() -> setupReplicatedRegionWithEviction(DATA_REGION_WITH_EVICTION_NAME));
Expand Down Expand Up @@ -220,6 +236,13 @@ private static void prepareDataForRegionWithSpecialCharacters(String regionPath)
dataRegion.put(2, "value%");
}

private static void prepareDataForRegionWithUUID(String regionPath) {
InternalCache cache = ClusterStartupRule.getCache();
Region<UUID, String> dataRegion = cache.getRegion(regionPath);

dataRegion.put(new UUID(1, 1), "value");
}

private static void prepareNotDeserializableDataForRegion(String regionPath) {
InternalCache cache = ClusterStartupRule.getCache();
Region dataRegion = cache.getRegion(regionPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -687,6 +688,8 @@ private void resolveObjectToColumns(Map<String, String> columnData, Object value
resolvePdxToColumns(columnData, (PdxInstance) value);
} else if (value instanceof Struct) {
resolveStructToColumns(columnData, (StructImpl) value);
} else if (value instanceof UUID) {
columnData.put("Result", valueToJson(value));
} else {
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.valueToTree(value);
Expand Down