Skip to content

Commit b967119

Browse files
Upgrade Npgsql to a non vulnerable version (#3545)
Co-authored-by: Alex Zaytsev <hazzik@gmail.com>
1 parent fdd7fcf commit b967119

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using System.Data.Common;
32
using NHibernate.Exceptions;
3+
using Npgsql;
44

55
namespace NHibernate.Test.ExceptionsTest
66
{
@@ -10,23 +10,23 @@ public class PostgresExceptionConverterExample : ISQLExceptionConverter
1010

1111
public Exception Convert(AdoExceptionContextInfo exInfo)
1212
{
13-
var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as DbException;
14-
if (sqle != null)
13+
if (ADOExceptionHelper.ExtractDbException(exInfo.SqlException) is PostgresException pge)
1514
{
16-
string code = (string)sqle.GetType().GetProperty("Code").GetValue(sqle, null);
17-
15+
string code = pge.SqlState;
1816
if (code == "23503")
1917
{
20-
return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null);
18+
return new ConstraintViolationException(exInfo.Message, pge.InnerException, exInfo.Sql, null);
2119
}
20+
2221
if (code == "42P01")
2322
{
24-
return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql);
23+
return new SQLGrammarException(exInfo.Message, pge.InnerException, exInfo.Sql);
2524
}
2625
}
26+
2727
return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql);
2828
}
2929

3030
#endregion
3131
}
32-
}
32+
}

src/NHibernate.Test/NHibernate.Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
6767
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
6868
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="8.5.2" />
69-
<PackageReference Include="Npgsql" Version="6.0.6" />
69+
<PackageReference Include="Npgsql" Version="8.0.3" />
7070
<PackageReference Include="MySql.Data" Version="8.0.30" />
7171
</ItemGroup>
7272
<ItemGroup Condition="$(NhNetFx)">

0 commit comments

Comments
 (0)