Skip to content

Commit

Permalink
Fix for an embarrassing bug in the managed partitions. 7.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Sep 26, 2024
1 parent 34ab363 commit eac0791
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Version>7.11.1</Version>
<Version>7.11.2</Version>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Extensions.Logging.Abstractions;
using Npgsql;
using Weasel.Core;
using Weasel.Core.Migrations;
Expand Down Expand Up @@ -64,6 +65,35 @@ public async Task migrate_tables_smoke_test()

}

[Fact]
public async Task migrate_tables_smoke_test_with_variable_value_and_tenant_id()
{
var database = new ManagedListDatabase();
var partitions = new Dictionary<string, string> { { Guid.NewGuid().ToString(), "red" }, { Guid.NewGuid().ToString(), "green" }, { Guid.NewGuid().ToString(), "blue" }, };
//await database.Partitions.ResetValues(database, partitions, CancellationToken.None);

await database.Partitions.AddPartitionToAllTables(NullLogger.Instance, database, partitions, CancellationToken.None);

await database.ApplyAllConfiguredChangesToDatabaseAsync();

var tables = await database.FetchExistingTablesAsync();

var teams = tables.Single(x => x.Identifier.Name == "teams");
var partitioning = teams.Partitioning.ShouldBeOfType<ListPartitioning>();
partitioning.HasExistingDefault.ShouldBeFalse();
partitioning.Partitions.Select(x => x.Suffix).OrderBy(x => x)
.ShouldBe(new []{"blue", "green", "red"});

var players = tables.Single(x => x.Identifier.Name == "players");
partitioning = players.Partitioning.ShouldBeOfType<ListPartitioning>();
partitioning.HasExistingDefault.ShouldBeFalse();
partitioning.Partitions.Select(x => x.Suffix).OrderBy(x => x)
.ShouldBe(new []{"blue", "green", "red"});

}



[Fact]
public async Task apply_additive_migration()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public async Task InitializeAsync(NpgsqlConnection conn, CancellationToken token
{
var value = await reader.GetFieldValueAsync<string>(0, token).ConfigureAwait(false);
var suffix = value.ToLowerInvariant();
if (await reader.IsDBNullAsync(1, token).ConfigureAwait(false))
if (!(await reader.IsDBNullAsync(1, token).ConfigureAwait(false)))
{
suffix =
(await reader.GetFieldValueAsync<string>(1, token).ConfigureAwait(false)).ToLowerInvariant();
Expand Down

0 comments on commit eac0791

Please sign in to comment.