Skip to content

Commit 0d071ff

Browse files
committed
NH-3996 - Add new PostgreSql83 Dialect which supports XML type
1 parent 78fd45b commit 0d071ff

File tree

10 files changed

+38
-20
lines changed

10 files changed

+38
-20
lines changed

doc/reference/modules/configuration.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,13 @@ ISession session = sessions.OpenSession(conn);
675675
available in PostgreSQL 8.2.
676676
</entry>
677677
</row>
678+
<row>
679+
<entry>PostgreSQL 8.3</entry>
680+
<entry><literal>NHibernate.Dialect.PostgreSQL83Dialect</literal></entry>
681+
<entry>
682+
This dialect supports <literal>XML</literal> type.
683+
</entry>
684+
</row>
678685
<row>
679686
<entry>MySQL 3 or 4</entry>
680687
<entry><literal>NHibernate.Dialect.MySQLDialect</literal></entry>

src/NHibernate.Config.Templates/PostgreSQL.cfg.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ for your own use before compile tests in VisualStudio.
1010
<property name="connection.connection_string">
1111
Server=localhost;Database=nhibernate;User ID=nhibernate;Password=nhibernate;
1212
</property>
13-
<property name="dialect">NHibernate.Dialect.PostgreSQL82Dialect</property>
13+
<property name="dialect">NHibernate.Dialect.PostgreSQL83Dialect</property>
1414
</session-factory>
15-
</hibernate-configuration>
15+
</hibernate-configuration>

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using NHibernate.Dialect;
1010
using NHibernate.Driver;
1111
using NHibernate.Linq;
12+
using NHibernate.SqlTypes;
1213
using NHibernate.Util;
1314
using NUnit.Framework;
1415

@@ -22,20 +23,10 @@ public class Fixture : BugTestCase
2223
private const int _totalEntityCount = 10;
2324
private readonly DateTime _testDate = DateTime.Now;
2425
private readonly DateTimeOffset _testDateWithOffset = DateTimeOffset.Now;
25-
26+
2627
protected override bool AppliesTo(Dialect.Dialect dialect)
2728
{
28-
var typeNames = (TypeNames)typeof(Dialect.Dialect).GetField("_typeNames", ReflectHelper.AnyVisibilityInstance).GetValue(Dialect);
29-
try
30-
{
31-
typeNames.Get(DbType.DateTimeOffset);
32-
}
33-
catch (ArgumentException)
34-
{
35-
return false;
36-
}
37-
38-
return true;
29+
return TestDialect.SupportsSqlType(new SqlType(DbType.DateTimeOffset));
3930
}
4031

4132
protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory)

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@
14351435
<Compile Include="TestCaseMappingByCode.cs" />
14361436
<Compile Include="TestDialect.cs" />
14371437
<Compile Include="TestDialects\MsSql2008TestDialect.cs" />
1438-
<Compile Include="TestDialects\PostgreSQL82TestDialect.cs" />
1438+
<Compile Include="TestDialects\PostgreSQL83TestDialect.cs" />
14391439
<Compile Include="TestDialects\SQLiteTestDialect.cs" />
14401440
<Compile Include="Tools\hbm2ddl\SchemaExportTests\ExportToFileFixture.cs" />
14411441
<Compile Include="TransformTests\ImplementationOfEqualityTests.cs" />
@@ -3518,10 +3518,10 @@
35183518
<Content Include="DbScripts\MsSql2012DialectLinqReadonlyDropScript.sql">
35193519
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
35203520
</Content>
3521-
<Content Include="DbScripts\PostgreSQL82DialectLinqReadonlyCreateScript.sql">
3521+
<Content Include="DbScripts\PostgreSQL83DialectLinqReadonlyCreateScript.sql">
35223522
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
35233523
</Content>
3524-
<Content Include="DbScripts\PostgreSQL82DialectLinqReadonlyDropScript.sql">
3524+
<Content Include="DbScripts\PostgreSQL83DialectLinqReadonlyDropScript.sql">
35253525
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
35263526
</Content>
35273527
<Content Include="DynamicEntity\package.html" />

src/NHibernate.Test/TestDialects/PostgreSQL82TestDialect.cs renamed to src/NHibernate.Test/TestDialects/PostgreSQL83TestDialect.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace NHibernate.Test.TestDialects
77
{
8-
public class PostgreSQL82TestDialect : TestDialect
8+
public class PostgreSQL83TestDialect : TestDialect
99
{
10-
public PostgreSQL82TestDialect(Dialect.Dialect dialect)
10+
public PostgreSQL83TestDialect(Dialect.Dialect dialect)
1111
: base(dialect)
1212
{
1313
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Data;
2+
3+
namespace NHibernate.Dialect
4+
{
5+
/// <summary>
6+
/// An SQL dialect for PostgreSQL 8.3 and above.
7+
/// </summary>
8+
/// <remarks>
9+
/// PostgreSQL 8.3 supports xml type
10+
/// </remarks>
11+
public class PostgreSQL83Dialect : PostgreSQL82Dialect
12+
{
13+
public PostgreSQL83Dialect()
14+
{
15+
//https://www.postgresql.org/docs/8.3/static/datatype-xml.html
16+
RegisterColumnType(DbType.Xml, "xml");
17+
}
18+
}
19+
}

src/NHibernate/NHibernate.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
<Compile Include="Connection\DriverConnectionProvider.cs" />
145145
<Compile Include="Connection\IConnectionProvider.cs" />
146146
<Compile Include="Connection\UserSuppliedConnectionProvider.cs" />
147+
<Compile Include="Dialect\PostgreSQL83Dialect.cs" />
147148
<Compile Include="Tool\hbm2ddl\IDatabaseMetadata.cs" />
148149
<Compile Include="Util\DelegateHelper.cs" />
149150
<Compile Include="Dialect\BitwiseFunctionOperation.cs" />

teamcity.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139

140140
<target name="setup-teamcity-postgresql">
141141
<property name="nhibernate.connection.driver_class" value="NHibernate.Driver.NpgsqlDriver" />
142-
<property name="nhibernate.dialect" value="NHibernate.Dialect.PostgreSQL82Dialect" />
142+
<property name="nhibernate.dialect" value="NHibernate.Dialect.PostgreSQL83Dialect" />
143143
<property name="nhibernate.connection.connection_string" value="Host=localhost;Port=5432;Database=nhibernate;Username=nhibernate;Password=nhibernate" />
144144
<copy todir="${bin.dir}">
145145
<fileset basedir="${root.dir}/lib/teamcity/postgresql">

0 commit comments

Comments
 (0)