zzzprojects / EntityFramework-Extensions

Entity Framework Bulk Operations | Improve Entity Framework performance with Bulk SaveChanges, Insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL and SQLite.
https://entityframework-extensions.net
346 stars 57 forks source link

As of Npgsql v4, DataReader column name is no longer case insensitive #92

Closed tedypranolo closed 6 years ago

tedypranolo commented 6 years ago

NpgsqlDataReader column name case insensitivity has been removed https://github.com/npgsql/npgsql/commit/05f2c2ce723f1987e5a1639ae61f193ed3474190#diff-d898bd0452e1175f84ff5ce0d2776cc4

I now get this exception on BulkInsert, which I assume is due to this change. Exception: Exception thrown: 'System.IndexOutOfRangeException' in Npgsql.dll Exception thrown: 'System.Exception' in Z.EntityFramework.Extensions.EFCore.dll An unhandled exception of type 'System.Exception' occurred in Z.EntityFramework.Extensions.EFCore.dll An error occured while retrieving the InformationSchemaTable information. See the inner exception for details.

Sql trace:

SELECT  
    table_schema AS BaseSchemaName,
    table_name AS BaseTableName,
    column_name AS ColumnName,
    data_type as DateType,
    ordinal_position AS Ordinal,
    CASE WHEN EXISTS (
        SELECT 1 FROM
        INFORMATION_SCHEMA.TABLE_CONSTRAINTS X 
        JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS Y USING (constraint_schema, constraint_name) 
        WHERE X.constraint_type = 'PRIMARY KEY' AND X.table_name = A.table_name AND Y.column_name = A.column_name) 
    THEN 1 ELSE 0 END AS IsKey,
    CASE WHEN pg_get_serial_sequence('kanjivg."' || TABLE_NAME || '"', COLUMN_NAME) IS NOT NULL
    THEN 1 ELSE 0 END AS IsIdentity
FROM INFORMATION_SCHEMA.COLUMNS AS A
WHERE TABLE_SCHEMA = 'kanjivg' AND  TABLE_NAME = 'character'
JonathanMagnan commented 6 years ago

Hello @tedypranolo ,

Just to give you an update.

This issue about case sensitive has been fixed a few days ago. However, we found out that some other breaking changes from Npgsql was also affecting our library.

Unless we find something else, I believe a new version will be available tomorrow.

Best Regards,

Jonathan

tedypranolo commented 6 years ago

Thank you for the fix.

JonathanMagnan commented 6 years ago

Hello @tedypranolo ,

The v2.1.8 has been released.

We believe that we fixed all compatibility issue with the preview version of Npgsql.

Let us know if you find something else on your side.

Best Regards,

Jonathan

rbanks54 commented 6 years ago

Not quite :-)

Case sensitivity in the schema name also breaks the statement @tedypranolo posted.

It needs to be

 SELECT
           table_schema AS BaseSchemaName,
           table_name AS BaseTableName,
           column_name AS ColumnName,
           data_type as DateType,
           ordinal_position AS Ordinal,
           CASE WHEN EXISTS (
                   SELECT 1 FROM
                   INFORMATION_SCHEMA.TABLE_CONSTRAINTS X
                   JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS Y USING (constraint_schema, constraint_name)
                   WHERE X.constraint_type = 'PRIMARY KEY' AND X.table_name = A.table_name AND Y.column_name = A.column_name)
           THEN 1 ELSE 0 END AS IsKey,
       CASE WHEN pg_get_serial_sequence('"' || TABLE_SCHEMA || '"."' || TABLE_NAME || '"', COLUMN_NAME) IS NOT NULL

       THEN 1 ELSE 0 END AS IsIdentity
   FROM INFORMATION_SCHEMA.COLUMNS AS A
   WHERE TABLE_SCHEMA = 'MySchemaName' AND  TABLE_NAME = 'MyTableName'

Note the change in the pg_get_serial_sequence() call.

JonathanMagnan commented 6 years ago

Damn ;)

Thank for reporting, we will look at it.

Best Regards,

Jonathan

JonathanMagnan commented 6 years ago

Hello @tedypranolo , @rbanks54 ,

The v2.1.11 has been released.

The issue is fixed and we tested as well the preview2 that has been released a few days ago.

They renamed the Commit method with Complete, so we fixed it as well.

Let us know if there is still more issue.

Best Regards,

Jonathan

JonathanMagnan commented 6 years ago

Hello @tedypranolo , @rbanks54 ,

This issue will be closed since it has been resolved.

Feel free to reopen it if you feel otherwise.

Best Regards,

Jonathan