Skip to content

Commit b57c46f

Browse files
fixup! Support evaluation of DateTime.Now on db side
Switch legacy pre-evaluation on by default
1 parent 01329aa commit b57c46f

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

doc/reference/modules/configuration.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ var session = sessions.OpenSession(conn);
722722
<literal>linqtohql.legacy_preevaluation</literal>
723723
</entry>
724724
<entry>
725-
Whether to use the legacy pre-evaluation or not in Linq queries. Defaults to <literal>false</literal>.
725+
Whether to use the legacy pre-evaluation or not in Linq queries. Defaults to <literal>true</literal>.
726726
<para>
727727
<emphasis role="strong">eg.</emphasis>
728728
<literal>true</literal> | <literal>false</literal>
@@ -738,6 +738,9 @@ var session = sessions.OpenSession(conn);
738738
UUIDs for each row instead of an unique one for all rows. (This does not happen if the dialect does
739739
not support the required HQL function.)
740740
</para>
741+
<para>
742+
The new pre-evaluation will likely be enabled by default in the next major version (6.0).
743+
</para>
741744
</entry>
742745
</row>
743746
<row>

src/NHibernate.Test/Async/Linq/PreEvaluationTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ protected override void Configure(Configuration configuration)
3030
base.Configure(configuration);
3131

3232
configuration.SetProperty(Environment.FormatSql, "false");
33-
if (LegacyPreEvaluation)
34-
configuration.SetProperty(Environment.LinqToHqlLegacyPreEvaluation, "true");
33+
configuration.SetProperty(Environment.LinqToHqlLegacyPreEvaluation, LegacyPreEvaluation.ToString());
3534
}
3635

3736
[Test]

src/NHibernate.Test/Linq/PreEvaluationTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ protected override void Configure(Configuration configuration)
1818
base.Configure(configuration);
1919

2020
configuration.SetProperty(Environment.FormatSql, "false");
21-
if (LegacyPreEvaluation)
22-
configuration.SetProperty(Environment.LinqToHqlLegacyPreEvaluation, "true");
21+
configuration.SetProperty(Environment.LinqToHqlLegacyPreEvaluation, LegacyPreEvaluation.ToString());
2322
}
2423

2524
[Test]

src/NHibernate/Cfg/Environment.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public static string Version
227227
public const string LinqToHqlGeneratorsRegistry = "linqtohql.generatorsregistry";
228228

229229
/// <summary>
230-
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>false</c> by default.
230+
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>true</c> by default.
231231
/// </summary>
232232
/// <remarks>
233233
/// <para>
@@ -241,6 +241,9 @@ public static string Version
241241
/// UUIDs for each row instead of an unique one for all rows. (This does not happen if the dialect does
242242
/// not support the required HQL function.)
243243
/// </para>
244+
/// <para>
245+
/// The new pre-evaluation will likely be enabled by default in the next major version (6.0).
246+
/// </para>
244247
/// </remarks>
245248
public const string LinqToHqlLegacyPreEvaluation = "linqtohql.legacy_preevaluation";
246249

src/NHibernate/Cfg/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public Settings()
144144
public ILinqToHqlGeneratorsRegistry LinqToHqlGeneratorsRegistry { get; internal set; }
145145

146146
/// <summary>
147-
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>false</c> by default.
147+
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>true</c> by default.
148148
/// </summary>
149149
/// <remarks>
150150
/// <para>

src/NHibernate/Cfg/SettingsFactory.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public Settings BuildSettings(IDictionary<string, string> properties)
5454
settings.Dialect = dialect;
5555

5656
settings.LinqToHqlGeneratorsRegistry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(properties);
57-
settings.LinqToHqlLegacyPreEvaluation = PropertiesHelper.GetBoolean(Environment.LinqToHqlLegacyPreEvaluation, properties);
57+
// 6.0 TODO: default to false instead of true, and adjust documentation in xsd, xml comment on Environment
58+
// and Setting properties, and doc\reference.
59+
settings.LinqToHqlLegacyPreEvaluation = PropertiesHelper.GetBoolean(
60+
Environment.LinqToHqlLegacyPreEvaluation,
61+
properties,
62+
true);
5863

5964
#region SQL Exception converter
6065

src/NHibernate/nhibernate-configuration.xsd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
<xs:enumeration value="linqtohql.legacy_preevaluation">
156156
<xs:annotation>
157157
<xs:documentation>
158-
Whether to use the legacy pre-evaluation or not in Linq queries. false by default.
158+
Whether to use the legacy pre-evaluation or not in Linq queries. true by default.
159159

160160
Legacy pre-evaluation is causing special properties or functions like DateTime.Now or Guid.NewGuid()
161161
to be always evaluated with the .Net runtime and replaced in the query by parameter values.
@@ -164,6 +164,8 @@
164164
side. This allows for example to retrieve the server time instead of the client time, or to generate
165165
UUIDs for each row instead of an unique one for all rows. (This does not happen if the dialect does
166166
not support the required HQL function.)
167+
168+
The new pre-evaluation will likely be enabled by default in the next major version (6.0).
167169
</xs:documentation>
168170
</xs:annotation>
169171
</xs:enumeration>

0 commit comments

Comments
 (0)