Skip to content

Commit

Permalink
Few more tables issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gearama committed Dec 30, 2024
1 parent 049b7a6 commit c7e0d46
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 74 deletions.
56 changes: 2 additions & 54 deletions sdk/tables/azure-data-tables/inc/azure/data/tables/models.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace Azure { namespace Data { namespace Tables {

private:
QueryTablesPagedResponse(std::shared_ptr<TableServiceClient> tableServiceClient)
: m_tableServiceClient(std::move(tableServiceClient)){};
: m_tableServiceClient(std::move(tableServiceClient)) {};

friend class Azure::Data::Tables::TableServiceClient;
friend class Azure::Core::PagedResponse<QueryTablesPagedResponse>;
Expand Down Expand Up @@ -569,20 +569,6 @@ namespace Azure { namespace Data { namespace Tables {
*/
UpsertKind UpsertType = UpsertKind::Update;
};
/**
* @brief Add Entity options.
*
*/
struct AddEntityOptions : public UpsertEntityOptions
{
AddEntityOptions() = default;
/**
* @brief Create Entity options constructor.
*
* @param other Upsert Entity options.
*/
explicit AddEntityOptions(UpsertEntityOptions const& other) { (void)other; }
};

/**
* @brief Add Entity result.
Expand All @@ -596,25 +582,6 @@ namespace Azure { namespace Data { namespace Tables {
std::string ETag;
};

/**
* @brief Update Entity options.
*
*/
struct UpdateEntityOptions final
{
/**
* @brief Update Entity options default constructor.
*
*/
UpdateEntityOptions() = default;
/**
* @brief Update Entity options constructor.
*
* @param other Update Entity options.
*/
UpdateEntityOptions(UpsertEntityOptions const& other) { (void)other; }
};

/**
* @brief Update Entity result.
*
Expand All @@ -627,25 +594,6 @@ namespace Azure { namespace Data { namespace Tables {
std::string ETag;
};

/**
* @brief Merge Entity options.
*
*/
struct MergeEntityOptions final
{
/**
* @brief Merge Entity options default constructor.
*
*/
MergeEntityOptions() = default;
/**
* @brief Merge Entity options constructor.
*
* @param other Upsert Entity options.
*/
MergeEntityOptions(UpsertEntityOptions const& other) { (void)other; }
};

/**
* @brief Merge Entity result.
*
Expand Down Expand Up @@ -771,7 +719,7 @@ namespace Azure { namespace Data { namespace Tables {

private:
QueryEntitiesPagedResponse(std::shared_ptr<TableClient> tableClient)
: m_tableClient(std::move(tableClient)){};
: m_tableClient(std::move(tableClient)) {};

std::shared_ptr<TableClient> m_tableClient;
friend class Azure::Data::Tables::TableClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ namespace Azure { namespace Data { namespace Tables {
*/
Response<Models::AddEntityResult> AddEntity(
Models::TableEntity const& tableEntity,
Models::AddEntityOptions const& options = {},
Core::Context const& context = {});

/**
Expand All @@ -126,7 +125,6 @@ namespace Azure { namespace Data { namespace Tables {
*/
Response<Models::UpdateEntityResult> UpdateEntity(
Models::TableEntity const& tableEntity,
Models::UpdateEntityOptions const& options = {},
Core::Context const& context = {});

/**
Expand All @@ -139,7 +137,6 @@ namespace Azure { namespace Data { namespace Tables {
*/
Response<Models::MergeEntityResult> MergeEntity(
Models::TableEntity const& tableEntity,
Models::MergeEntityOptions const& options = {},
Core::Context const& context = {});

/**
Expand Down
23 changes: 8 additions & 15 deletions sdk/tables/azure-data-tables/src/table_clients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ TableClient::TableClient(
const std::string& tableName,
const TableClientOptions& options)
: TableClient(
std::string{
Azure::Core::Url(serviceUrl).GetAbsoluteUrl() + "/" + credential->GetSignature()},
tableName,
options)
std::string{
Azure::Core::Url(serviceUrl).GetAbsoluteUrl() + "/" + credential->GetSignature()},
tableName,
options)
{
}

Expand Down Expand Up @@ -442,10 +442,8 @@ Azure::Response<Models::DeleteTableResult> TableServiceClient::DeleteTable(

Azure::Response<Models::AddEntityResult> TableClient::AddEntity(
Models::TableEntity const& tableEntity,
Models::AddEntityOptions const& options,
Core::Context const& context)
{
(void)options;
auto url = m_url;
url.AppendPath(m_tableName);

Expand Down Expand Up @@ -474,10 +472,8 @@ Azure::Response<Models::AddEntityResult> TableClient::AddEntity(

Azure::Response<Models::UpdateEntityResult> TableClient::UpdateEntity(
Models::TableEntity const& tableEntity,
Models::UpdateEntityOptions const& options,
Core::Context const& context)
{
(void)options;
auto url = m_url;
url.AppendPath(
m_tableName + PartitionKeyFragment
Expand Down Expand Up @@ -519,10 +515,8 @@ Azure::Response<Models::UpdateEntityResult> TableClient::UpdateEntity(

Azure::Response<Models::MergeEntityResult> TableClient::MergeEntity(
Models::TableEntity const& tableEntity,
Models::MergeEntityOptions const& options,
Core::Context const& context)
{
(void)options;
auto url = m_url;
url.AppendPath(
m_tableName + PartitionKeyFragment
Expand Down Expand Up @@ -599,26 +593,25 @@ Azure::Response<Models::UpsertEntityResult> TableClient::UpsertEntity(
Models::UpsertEntityOptions const& options,
Core::Context const& context)
{
(void)options;
try
{
switch (options.UpsertType)
{
case Models::UpsertKind::Merge: {
auto response = MergeEntity(tableEntity, Models::MergeEntityOptions(options), context);
auto response = MergeEntity(tableEntity, context);
return Azure::Response<Models::UpsertEntityResult>(
Models::UpsertEntityResult(response.Value), std::move(response.RawResponse));
}
default: {
auto response = UpdateEntity(tableEntity, Models::UpdateEntityOptions(options), context);
auto response = UpdateEntity(tableEntity, context);
return Azure::Response<Models::UpsertEntityResult>(
Models::UpsertEntityResult(response.Value), std::move(response.RawResponse));
}
}
}
catch (const Azure::Core::RequestFailedException&)
{
auto response = AddEntity(tableEntity, Models::AddEntityOptions(options), context);
auto response = AddEntity(tableEntity, context);
return Azure::Response<Models::UpsertEntityResult>(
Models::UpsertEntityResult(response.Value), std::move(response.RawResponse));
}
Expand Down Expand Up @@ -881,7 +874,7 @@ std::string TableClient::PrepDeleteEntity(
+ entity.GetRowKey().Value + ClosingFragment);
returnValue += "DELETE " + url.GetAbsoluteUrl() + " HTTP/1.1\n";
returnValue += "Accept: application/json;odata=minimalmetadata\n";
// returnValue += "Prefer: return-no-content\n";
returnValue += "Prefer: return-no-content\n";
returnValue += "DataServiceVersion: 3.0;\n";
if (!entity.GetETag().Value.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions sdk/tables/azure-data-tables/test/ut/table_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ namespace Azure { namespace Data { namespace Test {
options.UpsertType = Azure::Data::Tables::Models::UpsertKind::Update;

entity.Properties["Product"] = TableEntityProperty("Tables2");
auto updateResponse = m_tableClient->MergeEntity(entity, options);
auto updateResponse = m_tableClient->MergeEntity(entity);

EXPECT_EQ(
updateResponse.RawResponse->GetStatusCode(), Azure::Core::Http::HttpStatusCode::NoContent);
Expand All @@ -388,7 +388,7 @@ namespace Azure { namespace Data { namespace Test {
options2.UpsertType = Azure::Data::Tables::Models::UpsertKind::Merge;
entity.Properties["Product3"] = TableEntityProperty("Tables3");
entity.SetETag(updateResponse.Value.ETag);
auto updateResponse2 = m_tableClient->MergeEntity(entity, options2);
auto updateResponse2 = m_tableClient->MergeEntity(entity);

EXPECT_EQ(
updateResponse2.RawResponse->GetStatusCode(), Azure::Core::Http::HttpStatusCode::NoContent);
Expand Down

0 comments on commit c7e0d46

Please sign in to comment.