diff --git a/src/api/SIGCM2.Application/Products/NullProductQueryRepository.cs b/src/api/SIGCM2.Application/Products/NullProductQueryRepository.cs
deleted file mode 100644
index 0f9b509..0000000
--- a/src/api/SIGCM2.Application/Products/NullProductQueryRepository.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using SIGCM2.Application.Abstractions.Persistence;
-
-namespace SIGCM2.Application.Products;
-
-///
-/// STUB — PRD-002 replaces the DI binding with a real Dapper impl against dbo.Product.
-/// Returns false for all queries so DeactivateProductTypeCommandHandler guard always passes.
-/// This is intentional for PRD-001: the mechanism is installed; the data feed arrives in PRD-002.
-///
-public sealed class NullProductQueryRepository : IProductQueryRepository
-{
- public Task ExistsActiveByProductTypeAsync(int productTypeId, CancellationToken ct = default)
- => Task.FromResult(false);
-}
diff --git a/src/api/SIGCM2.Infrastructure/Persistence/ProductQueryRepository.cs b/src/api/SIGCM2.Infrastructure/Persistence/ProductQueryRepository.cs
index 24fc3b6..4ee619b 100644
--- a/src/api/SIGCM2.Infrastructure/Persistence/ProductQueryRepository.cs
+++ b/src/api/SIGCM2.Infrastructure/Persistence/ProductQueryRepository.cs
@@ -19,16 +19,19 @@ public sealed class ProductQueryRepository : IProductQueryRepository
public async Task ExistsActiveByProductTypeAsync(int productTypeId, CancellationToken ct = default)
{
const string sql = """
- SELECT COUNT(1)
- FROM dbo.Product
- WHERE ProductTypeId = @ProductTypeId
- AND IsActive = 1
+ SELECT CASE
+ WHEN EXISTS (
+ SELECT 1 FROM dbo.Product
+ WHERE ProductTypeId = @ProductTypeId
+ AND IsActive = 1
+ ) THEN 1 ELSE 0
+ END
""";
await using var connection = _factory.CreateConnection();
await connection.OpenAsync(ct);
- var count = await connection.ExecuteScalarAsync(sql, new { ProductTypeId = productTypeId });
- return count > 0;
+ var result = await connection.ExecuteScalarAsync(sql, new { ProductTypeId = productTypeId });
+ return result == 1;
}
}
diff --git a/tests/SIGCM2.Application.Tests/ProductTypes/NullProductQueryRepositoryTests.cs b/tests/SIGCM2.Application.Tests/ProductTypes/NullProductQueryRepositoryTests.cs
deleted file mode 100644
index 175b4cc..0000000
--- a/tests/SIGCM2.Application.Tests/ProductTypes/NullProductQueryRepositoryTests.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using FluentAssertions;
-using SIGCM2.Application.Products;
-
-namespace SIGCM2.Application.Tests.ProductTypes;
-
-public class NullProductQueryRepositoryTests
-{
- private readonly NullProductQueryRepository _sut = new();
-
- [Fact]
- public async Task ExistsActiveByProductTypeAsync_AlwaysReturnsFalse()
- {
- var result = await _sut.ExistsActiveByProductTypeAsync(productTypeId: 1);
-
- result.Should().BeFalse();
- }
-
- [Fact]
- public async Task ExistsActiveByProductTypeAsync_WithCancellationToken_DoesNotThrow()
- {
- using var cts = new CancellationTokenSource();
- var act = async () => await _sut.ExistsActiveByProductTypeAsync(productTypeId: 999, ct: cts.Token);
-
- await act.Should().NotThrowAsync();
- }
-}