Skip to content
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

Fix ArgumentException : Column 'SQL_TYPE_NAME' does not belong to table DataTypes (#3438) #3439

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/NHibernate/Dialect/Schema/DB2MetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;

namespace NHibernate.Dialect.Schema
{
Expand Down Expand Up @@ -31,13 +32,24 @@ public override ISet<string> GetReservedWords()
result.Add(row["ReservedWord"].ToString());
}

if (IncludeDataTypesInReservedWords)
if (!IncludeDataTypesInReservedWords)
return result;

var dtTypes = Connection.GetSchema(DbMetaDataCollectionNames.DataTypes);

var typeNameColumnIndex = dtTypes.Columns.IndexOf("SQL_TYPE_NAME");

if (typeNameColumnIndex == -1)
{
typeNameColumnIndex = dtTypes.Columns.IndexOf("TypeName");

if (typeNameColumnIndex == -1)
return result;
}

foreach (DataRow row in dtTypes.Rows)
{
var dtTypes = Connection.GetSchema(DbMetaDataCollectionNames.DataTypes);
foreach (DataRow row in dtTypes.Rows)
{
result.Add(row["SQL_TYPE_NAME"].ToString());
}
result.Add(row[typeNameColumnIndex].ToString());
}

return result;
Expand Down
Loading