Skip to content

Commit

Permalink
[Tables] Fix Deserialization Issues within ListEntities (#40392)
Browse files Browse the repository at this point in the history
* Fixing json deserialization of binary data and OffsetDateTime

* Adding additional test to ensure parity between listEntities and getEntity

* Fixing json deserialization of binary data and OffsetDateTime

* Update Cspell for Tables

* Adding tests for Async Table Client

* Fixing Spelling Errors

* Test adjustments and re-recordings

* Updates to fix analyze phase issues

* Updates to fix analyze phase issues

* String constant refactoring.
Making SAS token tests live only

* String constant refactoring.
Making SAS token tests live only

* Introduce permanent parity between getEntity and listEntities

* Removed Unused Imports

* Removed Unused Imports

* Remove unused imports

* Adding Microsoft Copyright

* Adding Timeouts to blocking tests

* adjusting test to troubleshoot CI

* adjusting test to troubleshoot CI

* adjusting test to troubleshoot CI

* adjusting test to troubleshoot CI

* adjusting test to troubleshoot CI

* adjusting test to troubleshoot CI

* Updates to PR from Alan's comments

* Removed unused imports

* Removed unused imports

* Removed unused imports
  • Loading branch information
jairmyree authored Jun 12, 2024
1 parent 1e10323 commit 955e1ff
Show file tree
Hide file tree
Showing 11 changed files with 409 additions and 35 deletions.
8 changes: 8 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,14 @@
"ignoreRegExpList": [
"/\/\/\\s*(BEGIN:|END:).*/"
]
},
{
"filename": "sdk/tables/azure-data-tables/**",
"words": [
"upserts",
"upserted",
"raud"
]
}
],
"allowCompoundWords": true
Expand Down
2 changes: 1 addition & 1 deletion sdk/tables/azure-data-tables/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/tables/azure-data-tables",
"Tag": "java/tables/azure-data-tables_c0ae0ab9dc"
"Tag": "java/tables/azure-data-tables_88e2b1d681"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ private <T extends TableEntity> PagedResponse<T> listEntities(String nextPartiti
.setSelect(select)
.setFormat(OdataMetadataFormat.APPLICATION_JSON_ODATA_FULLMETADATA);


final ResponseBase<TablesQueryEntitiesHeaders, TableEntityQueryResponse> response =
tablesImplementation.getTables().queryEntitiesWithResponse(tableName, null, null,
nextPartitionKey, nextRowKey, queryOptions, contextValue);
Expand Down Expand Up @@ -1445,7 +1446,7 @@ public Response<Void> setAccessPoliciesWithResponse(List<TableSignedIdentifier>
* Executes all {@link TableTransactionAction actions} within the list inside a transaction. When the call
* completes, either all {@link TableTransactionAction actions} in the transaction will succeed, or if a failure
* occurs, all {@link TableTransactionAction actions} in the transaction will be rolled back.
* {@link TableTransactionAction Actions} are executed sequantially. Each {@link TableTransactionAction action}
* {@link TableTransactionAction Actions} are executed sequentially. Each {@link TableTransactionAction action}
* must operate on a distinct row key. Attempting to pass multiple {@link TableTransactionAction actions} that
* share the same row key will cause an error.
*
Expand Down Expand Up @@ -1533,7 +1534,7 @@ public TableTransactionResult submitTransaction(List<TableTransactionAction> tra
* Executes all {@link TableTransactionAction actions} within the list inside a transaction. When the call
* completes, either all {@link TableTransactionAction actions} in the transaction will succeed, or if a failure
* occurs, all {@link TableTransactionAction actions} in the transaction will be rolled back.
* {@link TableTransactionAction Actions} are executed sequantially. Each {@link TableTransactionAction action}
* {@link TableTransactionAction Actions} are executed sequentially. Each {@link TableTransactionAction action}
* must operate on a distinct row key. Attempting to pass multiple {@link TableTransactionAction actions} that
* share the same row key will cause an error.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.azure.core.util.Base64Util;


import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -23,6 +24,7 @@
* Entity Data Model (EDM) types
*/
public enum EntityDataModelType {

/**
* <strong>Edm.Binary</strong> Represents fixed- or variable-length binary data
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static boolean shouldGetEntityFieldsAsMap(Type type) {
}

@SuppressWarnings("unchecked")
private static <U> U deserializeTableEntityQueryResponse(JsonReader jsonReader) throws IOException {
public static <U> U deserializeTableEntityQueryResponse(JsonReader jsonReader) throws IOException {
return (U) jsonReader.readObject(reader -> {
TableEntityQueryResponse deserializedTableEntityQueryResponse = new TableEntityQueryResponse();
while (reader.nextToken() != JsonToken.END_OBJECT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package com.azure.data.tables.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.data.tables.implementation.TablesJacksonSerializer;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
Expand All @@ -17,7 +17,7 @@
* The properties for the table entity query response.
*/
@Fluent
public final class TableEntityQueryResponse implements JsonSerializable<TableEntityQueryResponse> {
public final class TableEntityQueryResponse implements JsonSerializable<TableEntityQueryResponse> {
/*
* The metadata response of the table.
*/
Expand All @@ -36,7 +36,7 @@ public TableEntityQueryResponse() {

/**
* Get the odataMetadata property: The metadata response of the table.
*
*
* @return the odataMetadata value.
*/
public String getOdataMetadata() {
Expand All @@ -45,7 +45,7 @@ public String getOdataMetadata() {

/**
* Set the odataMetadata property: The metadata response of the table.
*
*
* @param odataMetadata the odataMetadata value to set.
* @return the TableEntityQueryResponse object itself.
*/
Expand All @@ -56,7 +56,7 @@ public TableEntityQueryResponse setOdataMetadata(String odataMetadata) {

/**
* Get the value property: List of table entities.
*
*
* @return the value value.
*/
public List<Map<String, Object>> getValue() {
Expand All @@ -65,7 +65,7 @@ public List<Map<String, Object>> getValue() {

/**
* Set the value property: List of table entities.
*
*
* @param value the value value to set.
* @return the TableEntityQueryResponse object itself.
*/
Expand All @@ -88,31 +88,13 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {

/**
* Reads an instance of TableEntityQueryResponse from the JsonReader.
*
*
* @param jsonReader The JsonReader being read.
* @return An instance of TableEntityQueryResponse if the JsonReader was pointing to an instance of it, or null if
* it was pointing to JSON null.
* @throws IOException If an error occurs while reading the TableEntityQueryResponse.
*/
public static TableEntityQueryResponse fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
TableEntityQueryResponse deserializedTableEntityQueryResponse = new TableEntityQueryResponse();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("odata.metadata".equals(fieldName)) {
deserializedTableEntityQueryResponse.odataMetadata = reader.getString();
} else if ("value".equals(fieldName)) {
List<Map<String, Object>> value
= reader.readArray(reader1 -> reader1.readMap(reader2 -> reader2.readUntyped()));
deserializedTableEntityQueryResponse.value = value;
} else {
reader.skipChildren();
}
}

return deserializedTableEntityQueryResponse;
});
return TablesJacksonSerializer.deserializeTableEntityQueryResponse(jsonReader);
}
}
Loading

0 comments on commit 955e1ff

Please sign in to comment.