Bug Report T302676
Visible to All Users

InvalidCastException in the PostgreSqlConnectionProvider.CollectTablesToCreate method with npgsql 3.0.3 (PostgreSQL)

created 9 years ago

Hello,

I'm using npqsql.dll to connect to a PostgreSQL 9.4 database. After upgrading npqsql to 3.0.3 (and upgrading my assemblies to .Net 4.5), an InvalidCastException is thrown in C:\Program Files (x86)\DevExpress 14.2\Components\Sources\DevExpress.Xpo\DevExpress.Xpo\Providers\PostgreSQL.cs on line 454

C#
public override ICollection CollectTablesToCreate(ICollection tables) { Dictionary dbTables = new Dictionary(); Dictionary dbSchemaTables = new Dictionary(); string queryString = @"select c.relname, c.relkind, n.nspname from pg_class c join pg_namespace n on c.relnamespace = n.oid where c.relname in({0}) and (c.relkind = 'r' OR c.relkind = 'v')"; foreach (SelectStatementResultRow row in GetDataForTables(tables, null, queryString).Rows) { if (row.Values[0] is DBNull) continue; string tableName = (string)row.Values[0]; bool isView = (string)row.Values[1] == "v"; string tableSchemaName = (string)row.Values[2]; dbTables[tableName] = isView; dbSchemaTables.Add(string.Concat(tableSchemaName, ".", tableName), isView); }

The line

C#
bool isView = (string)row.Values[1] == "v";

is causing the exception since row.Values[1] is a char.

Regards,
Jan v/d Broek

Comments (1)
DevExpress Support Team 9 years ago

    Thank you for the report. We have reproduced the issue and are working on the fix.

    Answers approved by DevExpress Support

    created 9 years ago (modified 9 years ago)

    We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

    Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.