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

Fix NodaTime Duration mapping #2285

Merged
merged 1 commit into from
Feb 28, 2022
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 @@ -131,7 +131,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 @@ -516,6 +516,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