Skip to content

Commit fba2dee

Browse files
committed
fix: Manual changes after V3 sync
1 parent af22158 commit fba2dee

File tree

4 files changed

+16
-39
lines changed

4 files changed

+16
-39
lines changed

sdk/src/Core/Amazon.Util/AWSSDKUtils.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,16 +613,6 @@ public static DateTime ConvertFromUnixLongEpochSeconds(long seconds)
613613
return new DateTime(seconds * 10000000L + EPOCH_START.Ticks, DateTimeKind.Utc);
614614
}
615615

616-
/// <summary>
617-
/// Utility method for converting Unix epoch seconds to DateTime structure.
618-
/// </summary>
619-
/// <param name="seconds">The number of seconds since January 1, 1970.</param>
620-
/// <returns>Converted DateTime structure</returns>
621-
public static DateTime ConvertFromUnixLongEpochSeconds(long seconds)
622-
{
623-
return new DateTime(seconds * 10000000L + EPOCH_START.Ticks, DateTimeKind.Utc).ToLocalTime();
624-
}
625-
626616
/// <summary>
627617
/// Utility method for converting Unix epoch milliseconds to DateTime structure.
628618
/// </summary>

sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,6 @@ internal Key MakeKey(object hashKey, object rangeKey, ItemStorageConfig storageC
11731173
hashKeyEntry = Document.DateTimeToEpochSeconds(hashKeyEntry, hashKeyProperty.AttributeName);
11741174
if (storageConfig.AttributesToStoreAsEpochLong.Contains(hashKeyProperty.AttributeName))
11751175
hashKeyEntry = Document.DateTimeToEpochSecondsLong(hashKeyEntry, hashKeyProperty.AttributeName);
1176-
if (storageConfig.AttributesToStoreAsEpochLong.Contains(hashKeyProperty.AttributeName))
1177-
hashKeyEntry = Document.DateTimeToEpochSecondsLong(hashKeyEntry, hashKeyProperty.AttributeName);
11781176
var hashKeyEntryAttributeConversionConfig = new DynamoDBEntry.AttributeConversionConfig(flatConfig.Conversion, flatConfig.IsEmptyStringValueEnabled);
11791177
key[hashKeyProperty.AttributeName] = hashKeyEntry.ConvertToAttributeValue(hashKeyEntryAttributeConversionConfig);
11801178

@@ -1195,8 +1193,6 @@ internal Key MakeKey(object hashKey, object rangeKey, ItemStorageConfig storageC
11951193
rangeKeyEntry = Document.DateTimeToEpochSeconds(rangeKeyEntry, rangeKeyProperty.AttributeName);
11961194
if (storageConfig.AttributesToStoreAsEpochLong.Contains(rangeKeyProperty.AttributeName))
11971195
rangeKeyEntry = Document.DateTimeToEpochSecondsLong(rangeKeyEntry, rangeKeyProperty.AttributeName);
1198-
if (storageConfig.AttributesToStoreAsEpochLong.Contains(rangeKeyProperty.AttributeName))
1199-
rangeKeyEntry = Document.DateTimeToEpochSecondsLong(rangeKeyEntry, rangeKeyProperty.AttributeName);
12001196

12011197
var rangeKeyEntryAttributeConversionConfig = new DynamoDBEntry.AttributeConversionConfig(flatConfig.Conversion, flatConfig.IsEmptyStringValueEnabled);
12021198
key[rangeKeyProperty.AttributeName] = rangeKeyEntry.ConvertToAttributeValue(rangeKeyEntryAttributeConversionConfig);
@@ -1211,7 +1207,6 @@ internal Key MakeKey<T>(T keyObject, ItemStorageConfig storageConfig, DynamoDBFl
12111207
if (storageConfig.HasVersion) // if version field is defined, it would have been returned, so remove before making the key
12121208
keyAsStorage.Document[storageConfig.VersionPropertyStorage.AttributeName] = null;
12131209
Key key = new Key(keyAsStorage.Document.ToAttributeMap(flatConfig.Conversion, storageConfig.AttributesToStoreAsEpoch, storageConfig.AttributesToStoreAsEpochLong, flatConfig.IsEmptyStringValueEnabled));
1214-
Key key = new Key(keyAsStorage.Document.ToAttributeMap(flatConfig.Conversion, storageConfig.AttributesToStoreAsEpoch, storageConfig.AttributesToStoreAsEpochLong, flatConfig.IsEmptyStringValueEnabled));
12151210
ValidateKey(key, storageConfig);
12161211
return key;
12171212
}

sdk/src/Services/DynamoDBv2/Custom/DataModel/InternalModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ public void Validate(DynamoDBContext context)
209209
this.Converter = Utils.InstantiateConverter(ConverterType, context) as IPropertyConverter;
210210
}
211211

212+
if (StoreAsEpoch && StoreAsEpochLong)
213+
throw new InvalidOperationException(PropertyName + " must not set both StoreAsEpoch and StoreAsEpochLong as true at the same time.");
214+
212215
IPropertyConverter converter;
213216
if (context.ConverterCache.TryGetValue(MemberType, out converter) && converter != null)
214217
{

sdk/src/Services/DynamoDBv2/Custom/DocumentModel/Table.cs

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ internal Key MakeKey(Primitive hashKey, Primitive rangeKey)
475475
if (this.StoreAsEpochLong.Contains(rangeKeyName))
476476
rangeKey = KeyDateTimeToEpochSecondsLong(rangeKey, rangeKeyName);
477477

478-
if (this.StoreAsEpochLong.Contains(rangeKeyName))
479-
rangeKey = KeyDateTimeToEpochSecondsLong(rangeKey, rangeKeyName);
480-
481478
if (rangeKeyDescription.Type != rangeKey.Type)
482479
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
483480
"Schema for table {0}, range key {1}, is inconsistent with specified range key value.", TableName, hashKeyName));
@@ -505,28 +502,20 @@ private static Primitive KeyDateTimeToEpochSecondsLong(Primitive key, string att
505502

506503
internal void UpdateRequestUserAgentDetails(AmazonDynamoDBRequest request, bool isAsync)
507504
{
508-
((Amazon.Runtime.Internal.IAmazonWebServiceRequest)request).AddBeforeRequestHandler(isAsync ?
509-
new RequestEventHandler(this.UserAgentRequestEventHandlerAsync) :
510-
new RequestEventHandler(this.UserAgentRequestEventHandlerSync)
511-
);
512-
}
505+
if (request == null) return;
513506

514-
private void UserAgentRequestEventHandler(object sender, RequestEventArgs args, bool isAsync)
515-
{
516-
WebServiceRequestEventArgs wsArgs = args as WebServiceRequestEventArgs;
517-
if (wsArgs != null)
507+
var userAgentDetails = ((Runtime.Internal.IAmazonWebServiceRequest)request).UserAgentDetails;
508+
509+
userAgentDetails.AddUserAgentComponent("ft/ddb-hll");
510+
userAgentDetails.AddUserAgentComponent($"md/{(isAsync ? "TableAsync" : "TableSync")}");
511+
512+
if (this.TableConsumer == DynamoDBConsumer.DataModel)
518513
{
519-
var feature = string.Format(" ft/ddb-hll md/{0} md/{1}", this.TableConsumer, (isAsync ? "TableAsync" : "TableSync"));
520-
if (wsArgs.Headers.Keys.Contains(HeaderKeys.UserAgentHeader))
521-
{
522-
string currentUserAgent = wsArgs.Headers[HeaderKeys.UserAgentHeader];
523-
wsArgs.Headers[HeaderKeys.UserAgentHeader] = currentUserAgent + feature;
524-
}
525-
else if (wsArgs.Headers.Keys.Contains(HeaderKeys.XAmzUserAgentHeader))
526-
{
527-
string currentUserAgent = wsArgs.Headers[HeaderKeys.XAmzUserAgentHeader];
528-
wsArgs.Headers[HeaderKeys.XAmzUserAgentHeader] = currentUserAgent + feature;
529-
}
514+
userAgentDetails.AddFeature(UserAgentFeatureId.DDB_MAPPER);
515+
}
516+
else
517+
{
518+
userAgentDetails.AddUserAgentComponent($"md/{this.TableConsumer}");
530519
}
531520
}
532521

@@ -1344,7 +1333,7 @@ internal async Task<Document> GetItemHelperAsync(Key key, GetItemOperationConfig
13441333
}
13451334
#endif
13461335

1347-
#endregion
1336+
#endregion
13481337

13491338

13501339
#region UpdateItem

0 commit comments

Comments
 (0)