Skip to content

Commit

Permalink
Fix NodaTime Duration mapping (#2285)
Browse files Browse the repository at this point in the history
Fixes #2287

(cherry picked from commit 7a139e7)
  • Loading branch information
roji committed Feb 28, 2022
1 parent 23e0e82 commit 52cb60e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH
{ "date", new RelationalTypeMapping[] { _date } },
{ "time without time zone", new RelationalTypeMapping[] { _time } },
{ "time with time zone", new RelationalTypeMapping[] { _timetz } },
{ "interval", new RelationalTypeMapping[] { _periodInterval } },
{ "interval", new RelationalTypeMapping[] { _periodInterval, _durationInterval } },

{ "tsrange", LegacyTimestampBehavior
? new RelationalTypeMapping[] { _legacyTimestampInstantRange, _timestampLocalDateTimeRange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,29 @@ public void GenerateCodeLiteral_returns_OffsetTime_literal()

#region interval

[Fact]
public void Duration_is_properly_mapped()
{
var mapping = GetMapping(typeof(Duration));

Assert.Equal("interval", mapping.StoreType);
Assert.Same(typeof(Duration), mapping.ClrType);

Assert.Same(mapping, GetMapping(typeof(Duration), "interval"));
}

[Fact]
public void Period_is_properly_mapped()
{
var mapping = GetMapping(typeof(Period));

Assert.Equal("interval", mapping.StoreType);
Assert.Same(typeof(Period), mapping.ClrType);

Assert.Same(mapping, GetMapping(typeof(Period)));
Assert.Same(mapping, GetMapping(typeof(Period), "interval"));
}

[Fact]
public void GenerateSqlLiteral_returns_Period_literal()
{
Expand Down

0 comments on commit 52cb60e

Please sign in to comment.