Skip to content

Commit

Permalink
[add] PostgreSQL 8.3 dialect which uses timestamptz DateTime format
Browse files Browse the repository at this point in the history
  • Loading branch information
i4004 committed Apr 26, 2024
1 parent ae0bd2e commit 4f72526
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Simplify.FluentNHibernate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [3.2.0] - 2024-04-26

### Added

- PostgreSQL 8.3 dialect which uses timestamptz DateTime format

## [3.1.0] - 2024-03-24

### Added
Expand Down
5 changes: 5 additions & 0 deletions src/Simplify.FluentNHibernate/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Configuration;
using NHibernate.Dialect;
using NHibernate.Driver;
using Pas.Database.Session.Dialects;
using Simplify.FluentNHibernate.Dialects;
using Simplify.FluentNHibernate.Drivers;
using Simplify.FluentNHibernate.Interceptors;
Expand Down Expand Up @@ -613,6 +614,7 @@ public static class ConfigurationExtensions
PostgreSqlDialect.PostgreSQL81 => PostgreSQLConfiguration.PostgreSQL81,
PostgreSqlDialect.PostgreSQL82 => PostgreSQLConfiguration.PostgreSQL82,
PostgreSqlDialect.PostgreSQL83 => PostgreSQLConfiguration.PostgreSQL83,
PostgreSqlDialect.PostgreSQL83Z => PostgreSQLConfiguration.PostgreSQL83,
_ => throw new InvalidOperationException()
};

Expand All @@ -623,6 +625,9 @@ public static class ConfigurationExtensions
.Username(settings.UserName)
.Password(settings.UserPassword));

if (dialect == PostgreSqlDialect.PostgreSQL83Z)
clientConfiguration.Dialect<PostgreSql83ZDialect>();

additionalClientConfiguration?.Invoke(clientConfiguration);

fluentConfiguration.Database(clientConfiguration);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Data;
using NHibernate.Dialect;

namespace Pas.Database.Session.Dialects;

/// <summary>
/// Provides PostgreSQL dialect which uses timestamptz DateTime format
/// </summary>
public class PostgreSql83ZDialect : PostgreSQL83Dialect
{
/// <summary>
/// Initialize PostgreSql83WithUtcDialect
/// </summary>
public PostgreSql83ZDialect() => RegisterColumnType(DbType.DateTime, "timestamptz");
}
6 changes: 5 additions & 1 deletion src/Simplify.FluentNHibernate/Dialects/PostgreSqlDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public enum PostgreSqlDialect
/// <summary>
/// The PostgreSQL 8.3 dialect
/// </summary>
PostgreSQL83
PostgreSQL83,
/// <summary>
/// The PostgreSQL 8.3 dialect using timestamptz DateTime format
/// </summary>
PostgreSQL83Z
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Version>3.1</Version>
<Version>3.2</Version>

<Authors>Alexander Krylkov</Authors>
<Product>Simplify</Product>
Expand Down

0 comments on commit 4f72526

Please sign in to comment.