-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
AdoNet - be more explicit when extracting DateTime from IDataRecord #6968
Conversation
@mjameson-se Have you run the database tests for other providers? I think all should be fine as nothing should change except be explicit about the type and not use a generic that the connector then makes the inference with, but I just want to make sure. I think I can do that but it may be next Monday evening or maybe Sunday evening, unfortunately. Edit: If you have time and energy, copying comments from other functions as appropriate is fine. Useful in that case would to be to add in
(It's a clunky explanation, but to give a gist). No need for this, though. I may add myself later as this is a good piece of information to keep in code, I believe. |
Have been running into issues also with NodaTime (primarily due to Npgsql/EfCore global typemapping https://github.com/npgsql/efcore.pg/blob/f6e9789fc6b6e16e1ca700c3d311bc23e27a7b91/src/EFCore.PG.NodaTime/Extensions/NpgsqlNodaTimeDbContextOptionsBuilderExtensions.cs#L22) and this PR looks like it could solve them. Wrt to the comments from @veikkoeeva , I don't have experience with Azure Storage or DynamoDb but it doesn't appear their libraries use global type mapping the same way AdoNet does so changes shouldn't be necessary there afaik. Are there any other further blockers on this getting merged? (P.S tried to look at failing tests but Azure Devops is giving me a 'Build not found' error, would it be possible for someone to trigger a rerun? Thanks). |
@dave-b-code I have a faint memory of running tests and not remembering blockers. The database tests need to be run locally, I think. That is, cloning the repository, compiling and then maybe in VS Unit Test Window selecting either all or a subset of AdoNet tests. The configuration on supported databases is hardcoded currently to default connection string values and assume a server is running. To be on the safe side, I can run the tests sometime this week, I believe, if no one else does. |
@dave-b-code Looks good for the PR! For SQL Server, I take a guess the problem is MySQL ones should not have failed. I think the isolation level ought to be set in scripts to be a correct one. I think warrants further looking into, but of course not in this PR. About isolation levels: https://www.percona.com/blog/2021/02/11/various-types-of-innodb-transaction-isolation-levels-explained-using-terminal/. It should work with repeatable reads, I believe. |
Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com>
Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com>
Many thanks, @mjameson-se, @dave-b-code, and @veikkoeeva! |
…otnet#6968) * AdoNet - be more explicit when extracting DateTime from IDataRecord * Default should be nullable * Update src/AdoNet/Shared/Storage/DbExtensions.cs Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com> * Update src/AdoNet/Shared/Storage/DbExtensions.cs Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com> Co-authored-by: Michael Jameson <michael.jameson@pelco.com> Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com> Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com>
…6968) (#7463) * AdoNet - be more explicit when extracting DateTime from IDataRecord * Default should be nullable * Update src/AdoNet/Shared/Storage/DbExtensions.cs Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com> * Update src/AdoNet/Shared/Storage/DbExtensions.cs Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com> Co-authored-by: Michael Jameson <michael.jameson@pelco.com> Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com> Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com> Co-authored-by: Michael Jameson <mjameson.se@gmail.com> Co-authored-by: Michael Jameson <michael.jameson@pelco.com> Co-authored-by: dave-b-code <54420411+dave-b-code@users.noreply.github.com>
Context:
In my project, we are using Npgsql, NodaTime and Npgsql.NodaTime. As a result of this combination, the postgres date/time types (such as those used in the AdoNet membership table) get mapped to NodaTime types instead of BCL types by default, unless you explicitly request the column as DateTime via
IDataRecord.GetDateTime(...)
or similar.Without the changes here, I am getting an invalid cast exception at runtime because the Instant type returned by Npgsql is being cast to DateTime by the Orleans AdoNet code.