Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename NpgsqlUuid7ValueGenerator to NpgsqlSequentialGuidValueGenerator and make it public #3255

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ public override bool TrySelect(IProperty property, ITypeBase typeBase, out Value
=> property.ClrType.UnwrapNullableType() == typeof(Guid)
? property.ValueGenerated == ValueGenerated.Never || property.GetDefaultValueSql() is not null
? new TemporaryGuidValueGenerator()
: new NpgsqlUuid7ValueGenerator()
: new NpgsqlSequentialGuidValueGenerator()
: base.FindForType(property, typeBase, clrType);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Npgsql.EntityFrameworkCore.PostgreSQL.ValueGeneration.Internal;
namespace Npgsql.EntityFrameworkCore.PostgreSQL.ValueGeneration;

/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public class NpgsqlUuid7ValueGenerator : ValueGenerator<Guid>
public class NpgsqlSequentialGuidValueGenerator : ValueGenerator<Guid>
{
/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
Expand Down
7 changes: 4 additions & 3 deletions test/EFCore.PG.Tests/NpgsqlValueGeneratorSelectorTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.ValueGeneration.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.ValueGeneration;
using Npgsql.EntityFrameworkCore.PostgreSQL.ValueGeneration.Internal;

namespace Npgsql.EntityFrameworkCore.PostgreSQL;
Expand All @@ -21,7 +22,7 @@ public void Returns_built_in_generators_for_types_setup_for_value_generation()
AssertGenerator<TemporaryByteValueGenerator>("NullableByte");
AssertGenerator<TemporaryDecimalValueGenerator>("Decimal");
AssertGenerator<StringValueGenerator>("String");
AssertGenerator<NpgsqlUuid7ValueGenerator>("Guid");
AssertGenerator<NpgsqlSequentialGuidValueGenerator>("Guid");
AssertGenerator<BinaryValueGenerator>("Binary");
}

Expand Down Expand Up @@ -128,7 +129,7 @@ public void Returns_sequence_value_generators_when_configured_for_model()
AssertGenerator<NpgsqlSequenceHiLoValueGenerator<long>>("NullableLong", setSequences: true);
AssertGenerator<NpgsqlSequenceHiLoValueGenerator<short>>("NullableShort", setSequences: true);
AssertGenerator<StringValueGenerator>("String", setSequences: true);
AssertGenerator<NpgsqlUuid7ValueGenerator>("Guid", setSequences: true);
AssertGenerator<NpgsqlSequentialGuidValueGenerator>("Guid", setSequences: true);
AssertGenerator<BinaryValueGenerator>("Binary", setSequences: true);
}

Expand Down Expand Up @@ -216,7 +217,7 @@ public void NpgsqlUuid7ValueGenerator_creates_uuidv7()
{
var dtoNow = DateTimeOffset.UtcNow;
var net9Internal = Guid.CreateVersion7(dtoNow);
var custom = NpgsqlUuid7ValueGenerator.BorrowedFromNet9.CreateVersion7(dtoNow);
var custom = NpgsqlSequentialGuidValueGenerator.BorrowedFromNet9.CreateVersion7(dtoNow);
var bytenet9 = net9Internal.ToByteArray().AsSpan(0, 6);
var bytecustom = custom.ToByteArray().AsSpan(0, 6);
Assert.Equal(bytenet9, bytecustom);
Expand Down