Skip to content

Commit

Permalink
Fix nhibernate#1362 - Running Unit tests against SQLite fails on date…
Browse files Browse the repository at this point in the history
…time/UTC
  • Loading branch information
fredericDelaporte committed Oct 14, 2017
1 parent 63a288e commit b0a6fd3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions doc/reference/modules/configuration.xml
Expand Up @@ -820,6 +820,13 @@ var session = sessions.OpenSession(conn);
Set <literal>driver_class</literal> to
<literal>NHibernate.Driver.SQLite20Driver</literal>
for System.Data.SQLite provider for .NET 2.0.
<para>
Due to
<ulink url="https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36">the
behavior of System.Data.SQLite</ulink> with <literal>DateTime</literal>, consider using
<literal>DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;</literal> in the SQLite
connection string for preventing undesired time shifts with its default configuration.
</para>
</entry>
</row>
<row>
Expand Down
9 changes: 7 additions & 2 deletions src/NHibernate.Config.Templates/SQLite.cfg.xml
Expand Up @@ -7,9 +7,14 @@ for your own use before compile tests in VisualStudio.
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernate.Test">
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<!-- DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC,
which dodges the undesirable time conversion to local done on reads by System.Data.SQLite.
See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36
and https://github.com/nhibernate/nhibernate-core/issues/1362 -->
<property name="connection.connection_string">
Data Source=nhibernate.db
Data Source=nhibernate.db;
DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;
</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
</session-factory>
</hibernate-configuration>
</hibernate-configuration>
12 changes: 10 additions & 2 deletions teamcity.build
Expand Up @@ -108,8 +108,12 @@

<target name="setup-teamcity-sqlite32">
<property name="nhibernate.connection.driver_class" value="NHibernate.Driver.SQLite20Driver" />
<!-- DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC,
which dodges the undesirable time conversion to local done on reads by System.Data.SQLite.
See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36
and https://github.com/nhibernate/nhibernate-core/issues/1362 -->
<property name="nhibernate.dialect" value="NHibernate.Dialect.SQLiteDialect" />
<property name="nhibernate.connection.connection_string" value="Data Source=NHibernate.db" />
<property name="nhibernate.connection.connection_string" value="Data Source=NHibernate.db;DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;" />
<copy todir="${bin.dir}">
<fileset basedir="${root.dir}/lib/teamcity/sqlite/x86">
<include name="*.dll"/>
Expand All @@ -120,8 +124,12 @@
<target name="setup-teamcity-sqlite64">
<property name="nunit-x64" value="true" />
<property name="nhibernate.connection.driver_class" value="NHibernate.Driver.SQLite20Driver" />
<!-- DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC,
which dodges the undesirable time conversion to local done on reads by System.Data.SQLite.
See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36
and https://github.com/nhibernate/nhibernate-core/issues/1362 -->
<property name="nhibernate.dialect" value="NHibernate.Dialect.SQLiteDialect" />
<property name="nhibernate.connection.connection_string" value="Data Source=NHibernate.db" />
<property name="nhibernate.connection.connection_string" value="Data Source=NHibernate.db;DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;" />
<copy todir="${bin.dir}">
<fileset basedir="${root.dir}/lib/teamcity/sqlite/x64">
<include name="*.dll"/>
Expand Down

0 comments on commit b0a6fd3

Please sign in to comment.