Skip to content

Commit 4bdb8a5

Browse files
fixup! Support evaluation of DateTime.Now on db side
Switch legacy pre-evaluation on by default
1 parent 7c6e99c commit 4bdb8a5

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
@@ -216,7 +216,7 @@ public static string Version
216216
public const string LinqToHqlGeneratorsRegistry = "linqtohql.generatorsregistry";
217217

218218
/// <summary>
219-
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>false</c> by default.
219+
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>true</c> by default.
220220
/// </summary>
221221
/// <remarks>
222222
/// <para>
@@ -230,6 +230,9 @@ public static string Version
230230
/// UUIDs for each row instead of an unique one for all rows. (This does not happen if the dialect does
231231
/// not support the required HQL function.)
232232
/// </para>
233+
/// <para>
234+
/// The new pre-evaluation will likely be enabled by default in the next major version (6.0).
235+
/// </para>
233236
/// </remarks>
234237
public const string LinqToHqlLegacyPreEvaluation = "linqtohql.legacy_preevaluation";
235238

src/NHibernate/Cfg/Settings.cs

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

137137
/// <summary>
138-
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>false</c> by default.
138+
/// Whether to use the legacy pre-evaluation or not in Linq queries. <c>true</c> by default.
139139
/// </summary>
140140
/// <remarks>
141141
/// <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
@@ -148,7 +148,7 @@
148148
<xs:enumeration value="linqtohql.legacy_preevaluation">
149149
<xs:annotation>
150150
<xs:documentation>
151-
Whether to use the legacy pre-evaluation or not in Linq queries. false by default.
151+
Whether to use the legacy pre-evaluation or not in Linq queries. true by default.
152152

153153
Legacy pre-evaluation is causing special properties or functions like DateTime.Now or Guid.NewGuid()
154154
to be always evaluated with the .Net runtime and replaced in the query by parameter values.
@@ -157,6 +157,8 @@
157157
side. This allows for example to retrieve the server time instead of the client time, or to generate
158158
UUIDs for each row instead of an unique one for all rows. (This does not happen if the dialect does
159159
not support the required HQL function.)
160+
161+
The new pre-evaluation will likely be enabled by default in the next major version (6.0).
160162
</xs:documentation>
161163
</xs:annotation>
162164
</xs:enumeration>

0 commit comments

Comments
 (0)