Skip to content

Commit 62755a5

Browse files
committed
Fix strange error that caused some DateTime fields to not output in Json meta
1 parent 5f694ed commit 62755a5

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

query-engine/docs/query-engine-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ services:
5050
- 16686:16686
5151

5252
query-engine:
53-
image: ghcr.io/yaytay/query-engine-design-mode:0.0.67-main
53+
image: ghcr.io/yaytay/query-engine-design-mode:0.0.68-main
5454
ports:
5555
- 2000:8080
5656
volumes:

query-engine/src/main/java/uk/co/spudsoft/query/exec/fmts/json/FormatJsonInstance.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public FormatJsonInstance(WriteStream<Buffer> outputStream, FormatJson defn) {
117117
return start();
118118
}
119119
, row -> {
120-
logger.debug("Outputting row: {}", row);
121120
if (row.isEmpty()) {
122121
return Future.succeededFuture();
123122
} else if (started.get()) {
@@ -204,7 +203,13 @@ private Future<Void> start() {
204203
if (Strings.isNullOrEmpty(defn.getMetadataName())) {
205204
start = "{\"" + defn.getDataName() + "\":";
206205
} else {
207-
DataRow row = DataRow.create(types);
206+
logger.debug("Data types: {}", types);
207+
Types metaTypes = new Types();
208+
types.forEach((cd -> {
209+
metaTypes.putIfAbsent(cd.name(), DataType.String);
210+
}));
211+
logger.debug("Meta types: {}", metaTypes);
212+
DataRow metaRow = DataRow.create(metaTypes);
208213
types.forEach(cd -> {
209214
String typeName = cd.typeName();
210215
if (defn.isCompatibleTypeNames()) {
@@ -216,7 +221,7 @@ private Future<Void> start() {
216221
typeName = typeName.toLowerCase(Locale.ROOT);
217222
}
218223
}
219-
row.put(cd.name(), typeName);
224+
metaRow.put(cd.name(), typeName);
220225
});
221226
String insertTitle = "";
222227
if (!Strings.isNullOrEmpty(title)) {
@@ -226,7 +231,7 @@ private Future<Void> start() {
226231
if (!Strings.isNullOrEmpty(description)) {
227232
insertTitle = "\"description\":\"" + description.trim() + "\",";
228233
}
229-
start = "{\"" + defn.getMetadataName() + "\":{" + insertTitle + insertDesc + "\"fields\":" + toJson(row).toString() + "},\"" + defn.getDataName() + "\":" + OPEN_ARRAY;
234+
start = "{\"" + defn.getMetadataName() + "\":{" + insertTitle + insertDesc + "\"fields\":" + toJson(metaRow).toString() + "},\"" + defn.getDataName() + "\":" + OPEN_ARRAY;
230235
}
231236
return outputStream.write(Buffer.buffer(start));
232237
}

query-engine/src/main/java/uk/co/spudsoft/query/main/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class Version {
3434
/**
3535
* The project version, as set in the Maven pom.xml.
3636
*/
37-
public static final String MAVEN_PROJECT_VERSION = "0.0.67-main";
37+
public static final String MAVEN_PROJECT_VERSION = "0.0.68-main";
3838

3939
private Version() {
4040
}

query-engine/src/test/java/uk/co/spudsoft/query/main/MainQueryIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void testQuery() throws Exception {
210210
.statusCode(200)
211211
.extract().body().asString();
212212

213-
assertThat(body, startsWith("{\"meta\":{\"fields\":{\"dataId\":\"int\",\"ref\":\"string\",\"value\":\"string\",\"children\":\"string\"}},\"data\":[{\"dataId\":1,\"instant\":\"1971-05-07 03:00:00\",\"ref\":\"antiquewhite\",\"value\":\"first\",\"children\":\"one\"},"));
213+
assertThat(body, startsWith("{\"meta\":{\"fields\":{\"dataId\":\"int\",\"instant\":\"datetime\",\"ref\":\"string\",\"value\":\"string\",\"children\":\"string\"}},\"data\":[{\"dataId\":1,\"instant\":\"1971-05-07 03:00:00\",\"ref\":\"antiquewhite\",\"value\":\"first\",\"children\":\"one\"},"));
214214
assertThat(body, endsWith(",{\"dataId\":13,\"instant\":\"1971-05-20 15:00:00\",\"ref\":\"cadetblue\",\"value\":\"thirteenth\",\"children\":\"thirteen,twenty six,thirty nine,fifty two,sixty five,seventy eight\"}]}"));
215215

216216
body = given()

0 commit comments

Comments
 (0)