mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 11:51:13 +00:00
e9d6db077c
Two integration-test failures uncovered after the initial commit: 1) GetTilesByRegionAsync outer ORDER BY referenced 'updated_at' but the inner DISTINCT ON subquery aliased it to 'UpdatedAt' (Postgres folds to 'updatedat'). DISTINCT ON already guarantees one row per (latitude, longitude, ...) so the third tiebreak was unreachable; removed it. 2) Dapper 2.1.35 silently bypasses SqlMapper.TypeHandler<T> for enum types during read deserialization (Dapper issue #259). The TileSourceTypeHandler worked for writes but reads fell through to Enum.TryParse, which cannot map 'google_maps' to GoogleMaps. Pivoted: TileEntity.Source is now a string (the wire value). TileSource enum stays as the public producer surface in Common.Enums; TileSourceConverter (Common.Enums) provides ToWireValue / FromWireValue / IsValidWireValue at the boundary. TileSourceTypeHandler deleted; registration removed from DapperEnumTypeHandlers.RegisterAll. tile-storage.md Inv-5 amended to document the storage choice. _docs/LESSONS.md L-001 records the Dapper bypass for future cycles. Full suite passes (213 unit + integration suite incl. AZ-484 AC-1..AC-5, security SEC-01..SEC-04, AZ-356/362/357). Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
namespace SatelliteProvider.Common.Enums;
|
|
|
|
// AZ-484: contract v1.0.0 stores TileSource as a snake_case string
|
|
// ('google_maps', 'uav'). Dapper's TypeHandler<T> for enum types is bypassed
|
|
// during deserialization (Dapper issue #259), so we cannot rely on a Dapper
|
|
// handler to round-trip enum<->wire string. Instead, TileEntity stores the
|
|
// wire value as a plain string and producers/consumers convert through this
|
|
// helper at the boundary, preserving type safety in business code while
|
|
// avoiding the Dapper enum read bug.
|
|
public static class TileSourceConverter
|
|
{
|
|
public const string GoogleMapsWireValue = "google_maps";
|
|
public const string UavWireValue = "uav";
|
|
|
|
public static string ToWireValue(TileSource value) => value switch
|
|
{
|
|
TileSource.GoogleMaps => GoogleMapsWireValue,
|
|
TileSource.Uav => UavWireValue,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TileSource"),
|
|
};
|
|
|
|
public static TileSource FromWireValue(string wireValue)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(wireValue);
|
|
|
|
return wireValue.ToLowerInvariant() switch
|
|
{
|
|
GoogleMapsWireValue => TileSource.GoogleMaps,
|
|
UavWireValue => TileSource.Uav,
|
|
_ => throw new ArgumentException($"'{wireValue}' is not a defined member of enum TileSource", nameof(wireValue)),
|
|
};
|
|
}
|
|
|
|
public static bool IsValidWireValue(string? wireValue) =>
|
|
wireValue is GoogleMapsWireValue or UavWireValue;
|
|
}
|