Skip to content

Commit

Permalink
Merge pull request #129 from dlmelendez/rel/9.0
Browse files Browse the repository at this point in the history
TableQueryBuilder bug init filter
  • Loading branch information
dlmelendez authored Dec 4, 2024
2 parents d722296 + 1bdf710 commit 3742c2f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/dlmelendez/identityazuretable.git</RepositoryUrl>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>9.0.1</Version>
<Version>9.0.2</Version>
<PackageProjectUrl>https://dlmelendez.github.io/identityazuretable</PackageProjectUrl>
<!--<DebugType>Full</DebugType>-->
<!-- DebugType Full is needed for test code coverage, but .nuget symbols doesn't like it-->
Expand Down
2 changes: 1 addition & 1 deletion src/ElCamino.Azure.Data.Tables/TableQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void AppendCondition(ReadOnlySpan<char> condition)
{
_bufferQuery[0] = '(';
condition.CopyTo(_bufferQuery[1..]);
_bufferQuery[^1] = ')';
_bufferQuery[condition.Length + 1] = ')';
}
else
{
Expand Down
40 changes: 39 additions & 1 deletion tests/ElCamino.Azure.Data.Tables.Tests/TableQueryBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,45 @@ private async Task SetupTableAsync()
await _tableClient.CreateIfNotExistsAsync();
_output.WriteLine("Table created {0}", TableName);

}
}

[Fact]
public async Task QueryBuilderPropertyString()
{
string propertyName = "newProperty1";

//Create Table
await SetupTableAsync();
//Setup Entity
var key = "b-" + Guid.NewGuid().ToString("N");
_output.WriteLine("PartitionKey {0}", key);
_output.WriteLine("RowKey {0}", key);
var entity = new TableEntity(key, key);
Assert.Equal(default, entity.ETag);
Assert.Equal(default, entity.Timestamp);

//Execute Add
var addedEntity = await _tableClient.AddEntityWithHeaderValuesAsync(entity);
Stopwatch sw = new Stopwatch();

sw.Start();
TableQueryBuilder queryBuilderNull = new TableQueryBuilder();
string filterNullBuilder = queryBuilderNull
.AddFilter(new QueryCondition<string>(nameof(TableEntity.PartitionKey), QueryComparison.Equal, addedEntity.PartitionKey))
.CombineFilters(TableOperator.And)
.AddFilter(new QueryCondition<string>(nameof(TableEntity.RowKey), QueryComparison.Equal, addedEntity.RowKey))
.CombineFilters(TableOperator.And)
.AddFilter(new QueryCondition<string>(propertyName, QueryComparison.Equal, null))
.ToString();
sw.Stop();
_output.WriteLine($"{nameof(filterNullBuilder)}: {sw.Elapsed.TotalMilliseconds}ms");
_output.WriteLine($"{nameof(filterNullBuilder)}:{filterNullBuilder}");


//Assert
Assert.Equal(1, await _tableClient.QueryAsync<TableEntity>(filter: filterNullBuilder).CountAsync());

}

[Fact]
public async Task QueryBuilderNullPropertyString()
Expand Down

0 comments on commit 3742c2f

Please sign in to comment.