NETProvider icon indicating copy to clipboard operation
NETProvider copied to clipboard

FBZonedDateTime with legacy code

Open PaladinMattt opened this issue 1 year ago • 3 comments

We have legacy code that supports multiple database systems and had been using: DateTime dt = Convert.ChangeType(valueReturnedFromQuery, typeof(DateTime)); to get the datetime values. This works fine in our Firebird 3 systems, but in testing out migrating to Firebird 5, this throws the Exception: System.InvalidCastException: 'Object must implement IConvertible.' Is there a reason FBZonedDateTime does not implement IConvertible? It could return the DateTime in the local users time or UTC time.

This functionality could be behind an AppContext switch, much the same way Npgsql has done (Ngsql.EnableLegacyTimestampBehavior), where essentially DbDataType.TimeStampTZ is treated as DbDataType.TimeStamp

PaladinMattt avatar Jun 14 '24 18:06 PaladinMattt

No particular reason. And I don't see any problem adding IConvertible implementation.

cincuranet avatar Jun 18 '24 10:06 cincuranet

I pulled down the repo and am trying to setup my test environment to get all the tests to pass, but am having some difficulty. Some of the tests fail with: Unable to load DLL 'fbembed' or one of its dependencies: The specified module could not be found. (0x8007007E) Also, my EntityFramework tesks appear to fail, possibly because I have my test environment setup to not use the default port 3050, since I use that for other environments. Do you have a readme document or some other information that can help me get all my tests passing?

PaladinMattt avatar Jun 24 '24 20:06 PaladinMattt

The port is hardcoded here, but you can easily change it for your run.

For the fbembed, do you use tests.ps1 to run tests? It sets up everything needed (there's also tests_firebird_dir envvar that you can use to customize the path).

Finally, you can also create a draft PR and see the results of tests there.

cincuranet avatar Jun 26 '24 15:06 cincuranet

@PaladinMattt is a colleague of mine and asked if I could take a look since he is always busy upgrading these legacy systems 😆

I can reproduce this issue in a test, and can submit a PR with a proposed fix.

willibrandon avatar Oct 08 '24 02:10 willibrandon