Skip to content

Commit

Permalink
Fix scan pagination (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
lezzi authored Apr 13, 2021
1 parent 371178f commit 5cc5cc6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public void Dispose()
public void Advance(int count)
{
Debug.Assert(_rentedBuffer != null);
Debug.Assert(count >= 0);
Debug.Assert(_index <= _rentedBuffer.Length - count);

_index += count;
Expand Down
2 changes: 1 addition & 1 deletion src/EfficientDynamoDb/Internal/ErrorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static async ValueTask ProcessErrorAsync(DynamoDbContextMetadata metadata
"ValidationException" => new ValidationException(error.Message),
"IdempotentParameterMismatchException" => new IdempotentParameterMismatchException(error.Message),
"TransactionInProgressException" => new TransactionInProgressException(error.Message),
_ => new DdbException(error.Message)
_ => new DdbException(error.Message ?? type ?? string.Empty)
};
case HttpStatusCode.InternalServerError:
throw new InternalServerErrorException(error.Message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public static void WritePaginationToken(this DdbWriter writer, string pagination
{
writer.JsonWriter.WritePropertyName("ExclusiveStartKey");

writer.JsonWriter.WriteNullValue();
// Flush to make sure our changes don't overlap with pending changes
writer.JsonWriter.Flush();

// Dirty hack until System.Text.Json supports writing raw json
writer.BufferWriter.Advance(-4);
var bytesSize = Encoding.UTF8.GetByteCount(paginationToken);

var bytesWritten = Encoding.UTF8.GetBytes(paginationToken, writer.BufferWriter.GetSpan(bytesSize));
Expand Down

0 comments on commit 5cc5cc6

Please sign in to comment.