Skip to content

Commit 1644ce5

Browse files
committed
NH-3807 - Issues with Firebird driver in netstandard.
1 parent 0011421 commit 1644ce5

File tree

5 files changed

+72
-15
lines changed

5 files changed

+72
-15
lines changed

src/NHibernate.Test/ExceptionsTest/FbExceptionConverterExample.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ public Exception Convert(AdoExceptionContextInfo adoExceptionContextInfo)
1616
var sqle = ADOExceptionHelper.ExtractDbException(adoExceptionContextInfo.SqlException) as DbException;
1717
if (sqle != null)
1818
{
19-
if (sqle.ErrorCode == 335544466)
19+
#if NETCOREAPP2_0
20+
// As of v5.9.0.0, for netstandard 1.6, the FbException.ErrorCode is not an override, so we need to directly get it.
21+
var propertyInfo = sqle.GetType().GetProperty("ErrorCode");
22+
int sqleErrorCode = (int)(propertyInfo?.GetValue(sqle, null) ?? 0);
23+
#else
24+
var sqleErrorCode = sqle.ErrorCode;
25+
#endif
26+
27+
if (sqleErrorCode == 335544466)
2028
{
2129
return new ConstraintViolationException(adoExceptionContextInfo.Message, sqle.InnerException, adoExceptionContextInfo.Sql, null);
2230
}
23-
if (sqle.ErrorCode == 335544569)
31+
if (sqleErrorCode == 335544569)
2432
{
2533
return new SQLGrammarException(adoExceptionContextInfo.Message, sqle.InnerException, adoExceptionContextInfo.Sql);
2634
}

src/NHibernate.Test/NHSpecificTest/NH1274ExportExclude/NH1274ExportExcludeFixture.cs

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Reflection;
66
using NHibernate.Cfg;
77
using NHibernate.Criterion;
8+
using NHibernate.Dialect;
89
using NHibernate.Engine;
910
using NHibernate.Tool.hbm2ddl;
1011
using NUnit.Framework;
@@ -27,13 +28,13 @@ public void SchemaExport_Drop_CreatesDropScript()
2728

2829
if (dialect.SupportsIfExistsBeforeTableName)
2930
{
30-
Assert.IsTrue(s.Contains("drop table if exists Home_Drop"));
31-
Assert.IsTrue(s.Contains("drop table if exists Home_All"));
31+
Assert.That(s, Does.Contain("drop table if exists Home_Drop"));
32+
Assert.That(s, Does.Contain("drop table if exists Home_All"));
3233
}
3334
else
3435
{
35-
Assert.IsTrue(s.Contains("drop table Home_Drop"));
36-
Assert.IsTrue(s.Contains("drop table Home_All"));
36+
Assert.That(s, Does.Contain("drop table Home_Drop"));
37+
Assert.That(s, Does.Contain("drop table Home_All"));
3738
}
3839
}
3940

@@ -49,36 +50,52 @@ public void SchemaExport_Export_CreatesExportScript()
4950
var dialect = Dialect.Dialect.GetDialect(configuration.Properties);
5051
if (dialect.SupportsIfExistsBeforeTableName)
5152
{
52-
Assert.IsTrue(s.Contains("drop table if exists Home_Drop"));
53-
Assert.IsTrue(s.Contains("drop table if exists Home_All"));
53+
Assert.That(s, Does.Contain("drop table if exists Home_Drop"));
54+
Assert.That(s, Does.Contain("drop table if exists Home_All"));
5455
}
5556
else
5657
{
57-
Assert.IsTrue(s.Contains("drop table Home_Drop"));
58-
Assert.IsTrue(s.Contains("drop table Home_All"));
58+
Assert.That(s, Does.Contain("drop table Home_Drop"));
59+
Assert.That(s, Does.Contain("drop table Home_All"));
5960
}
6061

61-
Assert.IsTrue(s.Contains("create table Home_All"));
62-
Assert.IsTrue(s.Contains("create table Home_Export"));
62+
Assert.That(s, Does.Contain("create table Home_All"));
63+
Assert.That(s, Does.Contain("create table Home_Export"));
6364
}
6465

6566
[Test]
6667
public void SchemaExport_Update_CreatesUpdateScript()
6768
{
6869
Configuration configuration = GetConfiguration();
70+
71+
#if NETCOREAPP2_0
72+
if (Dialect.Dialect.GetDialect(configuration.Properties) is FirebirdDialect)
73+
{
74+
Assert.Ignore("Firebird driver doesn't implement GetSchema");
75+
}
76+
#endif
77+
6978
SchemaUpdate update = new SchemaUpdate(configuration);
7079
TextWriter tw = new StringWriter();
7180
update.Execute(tw.WriteLine, false);
7281

7382
string s = tw.ToString();
74-
Assert.IsTrue(s.Contains("create table Home_Update"));
75-
Assert.IsTrue(s.Contains("create table Home_All"));
83+
Assert.That(s, Does.Contain("create table Home_Update"));
84+
Assert.That(s, Does.Contain("create table Home_All"));
7685
}
7786

7887
[Test]
7988
public void SchemaExport_Validate_CausesValidateException()
8089
{
8190
Configuration configuration = GetConfiguration();
91+
92+
#if NETCOREAPP2_0
93+
if (Dialect.Dialect.GetDialect(configuration.Properties) is FirebirdDialect)
94+
{
95+
Assert.Ignore("Firebird driver doesn't implement GetSchema");
96+
}
97+
#endif
98+
8299
SchemaValidator validator = new SchemaValidator(configuration);
83100
try
84101
{
@@ -133,4 +150,4 @@ protected IList Mappings
133150
}
134151
}
135152
}
136-
}
153+
}

src/NHibernate.Test/NHSpecificTest/NH1593/Fixture.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Text;
22
using NHibernate.Cfg;
3+
using NHibernate.Dialect;
34
using NHibernate.Tool.hbm2ddl;
45

56
using NUnit.Framework;
@@ -13,6 +14,14 @@ public class Fixture
1314
public void SchemaUpdateAddsIndexesThatWerentPresentYet()
1415
{
1516
Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
17+
18+
#if NETCOREAPP2_0
19+
if (Dialect.Dialect.GetDialect(cfg.Properties) is FirebirdDialect)
20+
{
21+
Assert.Ignore("Firebird driver doesn't implement GetSchema");
22+
}
23+
#endif
24+
1625
cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", GetType().Assembly);
1726
var su = new SchemaUpdate(cfg);
1827
var sb = new StringBuilder(500);

src/NHibernate.Test/Tools/hbm2ddl/SchemaUpdate/MigrationFixture.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Reflection;
44
using NHibernate.Cfg;
5+
using NHibernate.Dialect;
56
using NHibernate.Driver;
67
using NHibernate.Tool.hbm2ddl;
78
using NHibernate.Util;
@@ -22,6 +23,13 @@ private void MigrateSchema(string resource1, string resource2)
2223
if (driverClass.IsOdbcDriver())
2324
Assert.Ignore("Test is not compatible with ODBC");
2425

26+
#if NETCOREAPP2_0
27+
if (Dialect.Dialect.GetDialect(v1cfg.Properties) is FirebirdDialect)
28+
{
29+
Assert.Ignore("Firebird driver doesn't implement GetSchema");
30+
}
31+
#endif
32+
2533
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource1))
2634
v1cfg.AddInputStream(stream);
2735
new SchemaExport(v1cfg).Execute(false, true, true);

src/NHibernate.Test/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reflection;
22
using NHibernate.Cfg;
3+
using NHibernate.Dialect;
34
using NHibernate.Tool.hbm2ddl;
45
using NUnit.Framework;
56

@@ -14,6 +15,13 @@ public void ShouldVerifySameTable()
1415
const string resource = "NHibernate.Test.Tools.hbm2ddl.SchemaValidator.1_Version.hbm.xml";
1516
var cfg = BuildConfiguration(resource);
1617

18+
#if NETCOREAPP2_0
19+
if (Dialect.Dialect.GetDialect(cfg.Properties) is FirebirdDialect)
20+
{
21+
Assert.Ignore("Firebird driver doesn't implement GetSchema");
22+
}
23+
#endif
24+
1725
new SchemaExport(cfg).Execute(true, true, false);
1826

1927
var validator = new Tool.hbm2ddl.SchemaValidator((cfg));
@@ -55,6 +63,13 @@ public void ShouldNotVerifyModifiedTable()
5563
const string resource2 = "NHibernate.Test.Tools.hbm2ddl.SchemaValidator.2_Version.hbm.xml";
5664
var cfgV2 = BuildConfiguration(resource2);
5765

66+
#if NETCOREAPP2_0
67+
if (Dialect.Dialect.GetDialect(cfgV2.Properties) is FirebirdDialect)
68+
{
69+
Assert.Ignore("Firebird driver doesn't implement GetSchema");
70+
}
71+
#endif
72+
5873
new SchemaExport(cfgV1).Execute(true, true, false);
5974

6075
var validatorV2 = new Tool.hbm2ddl.SchemaValidator(cfgV2);

0 commit comments

Comments
 (0)