question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NodaTime DateInterval Array and List (or any NodaTime type) are not mapped to datemultirange

See original GitHub issue

For NodaTime, it appears that both NodaTime.DateInterval[] and List<NodaTime.DateInterval> do not map to a datemultirange. Example from a migration script for properties:

local_date_should_be_of_type_date                                = table.Column<LocalDate>(type: "date", nullable: false),
npgsql_range_local_date_should_be_of_type_date_range             = table.Column<NpgsqlRange<LocalDate>>(type: "daterange", nullable: false),
npgsql_range_local_date_array_should_be_of_type_date_multi_range = table.Column<NpgsqlRange<LocalDate>[]>(type: "daterange[]", nullable: false),
date_interval_should_be_of_type_date_range                       = table.Column<DateInterval>(type: "daterange", nullable: false),
date_interval_array_should_be_of_type_multi_date_range           = table.Column<DateInterval[]>(type: "daterange[]", nullable: false),
list_date_interval_should_be_of_type_multi_date_range            = table.Column<List<DateInterval>>(type: "daterange[]", nullable: false),
npgsql_range_date_time_should_be_of_type_tstzmultirange          = table.Column<NpgsqlRange<DateTime>[]>(type: "tstzmultirange", nullable: false),
npgsql_range_date_only_should_be_of_type_date_multi_range        = table.Column<NpgsqlRange<DateOnly>[]>(type: "datemultirange", nullable: false),

Only the System. types are converted to multiranges. I expected:

local_date_should_be_of_type_date                                = table.Column<LocalDate>(type: "date", nullable: false),
npgsql_range_local_date_should_be_of_type_date_range             = table.Column<NpgsqlRange<LocalDate>>(type: "daterange", nullable: false),
npgsql_range_local_date_array_should_be_of_type_date_multi_range = table.Column<NpgsqlRange<LocalDate>[]>(type: "datemultirange", nullable: false),
date_interval_should_be_of_type_date_range                       = table.Column<DateInterval>(type: "daterange", nullable: false),
date_interval_array_should_be_of_type_multi_date_range           = table.Column<DateInterval[]>(type: "datemultirange", nullable: false),
list_date_interval_should_be_of_type_multi_date_range            = table.Column<List<DateInterval>>(type: "datemultirange", nullable: false),
npgsql_range_date_time_should_be_of_type_tstzmultirange          = table.Column<NpgsqlRange<DateTime>[]>(type: "tstzmultirange", nullable: false),
npgsql_range_date_only_should_be_of_type_date_multi_range        = table.Column<NpgsqlRange<DateOnly>[]>(type: "datemultirange", nullable: false),

I don’t see anything that would be doing it in code either Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs and the tests don’t seem to address NodaTime for example at EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs whereas Npgsql proper appears to support it as seen Npgsql.NodaTime/Internal/NodaTimeTypeHandlerResolver.cs. Is NodaTime support for datemultirange simply not implemented currently? or is this a bug? (or am I doing something wrong?)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Dec 22, 2021

@erichiller great to hear. In the meantime I released 6.0.2 including this change, so you can just try that.

1reaction
rojicommented, Dec 21, 2021

Shoot, looks like I missed the NodaTime multirange mappings - these were done in the underlying ADO.NET driver but not in EFCore.PG. I’ll do that for 6.0.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I accurately represent a Date Range in NodaTime?
I have a list of LocalDate items that represent sets of start dates and end dates. I would like to be able to...
Read more >
Class DateInterval | Noda Time
Returns the hash code for this interval, consistent with Equals(DateInterval). See the type documentation for a description of equality semantics.
Read more >
Namespace NodaTime | Noda Time
A calendar system maps the non-calendar-specific "local time line" to human concepts such as years, months and days. DateAdjusters. Factory class for date ......
Read more >
Noda Time | Date and time arithmetic
There are two types of arithmetic in Noda Time: arithmetic on the time line (in some sense "absolute" arithmetic), and calendrical arithmetic.
Read more >
Noda Time | Jon Skeet's coding blog
Posts about Noda Time written by jonskeet. ... NET built-in types – a signature of IsChargingEnabled(DateTime dateTime) would have needed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found