LinqToDB4iSeries / Linq2DB4iSeries

LinqToDB provider for the DB2 database on IBM iSeries
MIT License
18 stars 5 forks source link

V3.3.0 #52

Closed nsarris closed 3 years ago

nsarris commented 3 years ago

@devinlyons I have added a Tets howto file in this branch. Please run the tests and if you need to commit anything please create a PR on this branch (V3.3.0) from your fork.

devinlyons commented 3 years ago

I've run the tests and will start fixing issues. I attached a playlists with the failed tests.

Failed Tests.txt

devinlyons commented 3 years ago

@nsarris, I've been working on some of these tests and it seems like many of them have been failing for some time. What's your practice for dealing with broken tests?

nsarris commented 3 years ago

I have been running those those tests on a 7.4 system and on pub400 (when it's working). Up to the last release they were all working.

Bare in mind you need a license for the DB2 Connect tests to run and an appropriate version of the i Access Client drivers for the others (check link on wiki)

Other than that there might be new or changed tests that came with the new version of linq2db. The strategy for that is to override them in Tests.Base/Customization Support/Db2iInterceptor.cs

CustomizationSupport is infrastructure I committed to linq2db in order for tests to be customized. Db2iInterceptor.cs is the implementation of CustomizationSupport for Db2i. At this point don't bother with anything other than IntrceptTestDataSources. This method allows you to override the providers applicable to a test method.

nsarris commented 3 years ago

@devinlyons and sorry for the delayed response, it was easter holiday over here :)

devinlyons commented 3 years ago

@nsarris, I finally got some time to work on this but I hit a dead end. The test ConvertDate1 succeeds. However, the test ConvertDate2 fails for the DB2.iSeries.Net.* providers. It seems to have something to do with the way Timestamps are converted to Dates in the WHERE clause. I can't find the bug though. Do you have any suggestions on where to look?

Error Details:

Test Name:  CompareDate2("DB2.iSeries.Net.71")
Test FullName:  Tests (net472).Tests.DataProvider.DB2iSeriesTests.CompareDate2("DB2.iSeries.Net.71")
Test Source:    C:\Code\Linq2DB4iSeries\Tests\Linq\Custom\DB2iSeriesTests.Linq.cs : line 71
Test Outcome:   Failed
Test Duration:  0:00:00

Test Name:  CompareDate2("DB2.iSeries.Net.71")
Test Outcome:   Failed
Result StackTrace:  
at IBM.Data.DB2.iSeries.iDB2Exception.throwDcException(MpDcErrorInfo mpEI, MPConnection conn)
   at IBM.Data.DB2.iSeries.iDB2Command.openCursor()
   at IBM.Data.DB2.iSeries.iDB2Command.ExecuteDbDataReader(CommandBehavior behavior)
   at LinqToDB.Data.DataConnection.ExecuteReader(IDbCommand command, CommandBehavior commandBehavior)
   at LinqToDB.Data.DataConnection.ExecuteReader(CommandBehavior commandBehavior)
   at LinqToDB.Data.DataConnection.QueryRunner.ExecuteReader()
   at LinqToDB.Linq.QueryRunner.<ExecuteQuery>d__11`1.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Tests.TestBase.AreEqual[T](Func`2 fixSelector, IEnumerable`1 expected, IEnumerable`1 result, IEqualityComparer`1 comparer, Func`2 sort, Boolean allowEmpty) in C:\Code\Linq2DB4iSeries\Tests\Base\TestBase.cs:line 1105
   at Tests.TestBase.AreEqual[T](Func`2 fixSelector, IEnumerable`1 expected, IEnumerable`1 result, IEqualityComparer`1 comparer, Boolean allowEmpty) in C:\Code\Linq2DB4iSeries\Tests\Base\TestBase.cs:line 1094
   at Tests.TestBase.AreEqual[T](IEnumerable`1 expected, IEnumerable`1 result, Boolean allowEmpty) in C:\Code\Linq2DB4iSeries\Tests\Base\TestBase.cs:line 1059
   at Tests.DataProvider.DB2iSeriesTests.CompareDate2(String context) in C:\Code\Linq2DB4iSeries\Tests\Linq\Custom\DB2iSeriesTests.Linq.cs:line 86
Result Message: 
IBM.Data.DB2.iSeries.iDB2ConversionException : A conversion error occurred.
DB2iSeriesAccessClientProviderAdapter: IBM.Data.DB2.iSeries, Version=12.0.0.0, Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26
DataConnection: BeforeExecute
-- DB2.iSeries.Net.71 DB2iSeries
DECLARE @Date_1 iDB2TimeStamp -- DateTime
SET     @Date_1 = '2009-09-20 00:00:00'

SELECT
    t.ID,
    t.MoneyValue,
    t.DateTimeValue,
    t.DateTimeValue2,
    t.BoolValue,
    t.GuidValue,
    t.SmallIntValue,
    t.IntValue,
    t.BigIntValue,
    t.StringValue
FROM
    LinqDataTypes t
WHERE
    Date(t.DateTimeValue) > CAST(@Date_1 AS DATE)
nsarris commented 3 years ago

@devinlyons this driver is notoriously bad when converting data types. It can fail when converting from c# datatypes to sql or the other way around. From the stack trace I can see that this is a case where it fails converting from SQL since it has executed tha data reader. My guess is your iSeries is perhaps configured with a locale setting that produces incompatible date format. I think we got to a point where we should perhaps arrange a screen share if possible.

In the mean time, let's skip this particular test. Do the other tests complete? I guess you skipped the DB2Connect test since you probably don't have a license, correct? Do the tests that target the new feature complete ( Tests.Linq\TableOptionTests)?

devinlyons commented 3 years ago

@nsarris, there are about 500 tests failing. The ones I have looked at seem to be failing because of the date conversion issue.

I do not have a license for DB2Connect so I can't test it.

The new TableOptionsTests are failing. However, this appears to mostly be because the it's using CREATE GLOBAL TEMPORARY TABLE SESSION.IsGlobalTemporaryTable instead of DECLARE GLOBAL TEMPORARY TABLE SESSION.IsGlobalTemporaryTable.

devinlyons commented 3 years ago

@nsarris, I can't find where the session table code is generated. Can you point me in the right direction?

nsarris commented 3 years ago

@devinlyons Checkout the diff for Source/ISeriesProvider/DB2iSeriesSqlBuilder.cs

Methods BuildCreateTableCommand, BuildStartCreateTableStatement, BuildEndCreateTableStatement,GetTableSchemaName

These are copied over from the DB2 implentation of the TableOptions feature and obviously need some tweaking for iDB2.

I can see that it goes for DECLARE GLOBAL for most cases, and falls back to CREATE GLOBAL for option "IsGlobalTemporaryStructure". Is this unsupported in iDB2?

devinlyons commented 3 years ago

@nsarris, my company has reprioritized this and we would like to get this updated soon. We would even be willing to help maintain this library moving forward. Can we see about setting up that screen share so we can solve some of these issues? I would like to learn enough about this library to be able to maintain it.

I'm not comfortable sharing my email in a public repository. So, I'm going to set up a private one and give you access to it. I'll put my contact information in the readme so you can reach out to me. Thank you for your time.

nsarris commented 3 years ago

Sure go ahead, I will contact you and we can take it from there.

devinlyons commented 3 years ago

Done. You should have an invite to the repo.