-
Notifications
You must be signed in to change notification settings - Fork 933
NH-4062 - Oracle Unicode support dual model. #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -771,15 +771,13 @@ public void GroupByComputedValueInObjectArrayWithJoinOnId() | |
Assert.AreEqual(2155, orderGroups.Sum(g => g.Count)); | ||
} | ||
|
||
[Test(Description = "NH-3801")] | ||
[Test(Description = "NH-3801, NH-4062")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
public void GroupByComputedValueInObjectArrayWithJoinInRightSideOfCase() | ||
{ | ||
if (!TestDialect.SupportsComplexExpressionInGroupBy) | ||
Assert.Ignore(Dialect.GetType().Name + " does not support complex group by expressions"); | ||
if (Sfi.ConnectionProvider.Driver is OdbcDriver) | ||
Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); | ||
if (Dialect is Oracle8iDialect) | ||
Assert.Ignore("ORA-12704: character set mismatch. Due to NHibernate creating Unicode string types as NVarchar2 but querying them as Varchar2."); | ||
|
||
var orderGroups = db.OrderLines.GroupBy(o => new[] { o.Order.Customer.CustomerId == null ? "unknown" : o.Order.Customer.CompanyName }).Select(g => new { Key = g.Key, Count = g.Count() }).ToList(); | ||
Assert.AreEqual(2155, orderGroups.Sum(g => g.Count)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,20 @@ public static string Version | |
/// </summary> | ||
public const string OdbcDateTimeScale = "odbc.explicit_datetime_scale"; | ||
|
||
/// <summary> | ||
/// <para>Oracle has a dual Unicode support model.</para> | ||
/// <para>Either the whole database use an Unicode encoding, and then all string types | ||
/// will be Unicode. In such case, Unicode strings should be mapped to non <c>N</c> prefixed | ||
/// types, such as <c>Varchar2</c>. This is the default.</para> | ||
/// <para>Or <c>N</c> prefixed types such as <c>NVarchar2</c> are to be used for Unicode strings.</para> | ||
/// </summary> | ||
/// <remarks> | ||
/// See https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch6unicode.htm#CACHCAHF | ||
/// https://docs.oracle.com/database/121/ODPNT/featOraCommand.htm#i1007557 | ||
/// This setting applies only to Oracle dialects and ODP.Net managed or unmanaged driver. | ||
/// </remarks> | ||
public const string OracleUseNPrefixedTypesForUnicode = "oracle.use_n_prefixed_types_for_unicode"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New setting just for Oracle. |
||
|
||
private static readonly Dictionary<string, string> GlobalProperties; | ||
|
||
private static IBytecodeProvider BytecodeProviderInstance; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ public static Dialect GetDialect() | |
{ | ||
throw new HibernateException("The dialect was not set. Set the property 'dialect'.", e); | ||
} | ||
return InstantiateDialect(dialectName); | ||
return InstantiateDialect(dialectName, Environment.Properties); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -167,7 +167,7 @@ public static Dialect GetDialect() | |
public static Dialect GetDialect(IDictionary<string, string> props) | ||
{ | ||
if (props == null) | ||
throw new ArgumentNullException("props"); | ||
throw new ArgumentNullException(nameof(props)); | ||
string dialectName; | ||
if (props.TryGetValue(Environment.Dialect, out dialectName) == false) | ||
throw new InvalidOperationException("Could not find the dialect in the configuration"); | ||
|
@@ -176,21 +176,31 @@ public static Dialect GetDialect(IDictionary<string, string> props) | |
return GetDialect(); | ||
} | ||
|
||
return InstantiateDialect(dialectName); | ||
return InstantiateDialect(dialectName, props); | ||
} | ||
|
||
private static Dialect InstantiateDialect(string dialectName) | ||
private static Dialect InstantiateDialect(string dialectName, IDictionary<string, string> props) | ||
{ | ||
try | ||
{ | ||
return (Dialect)Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(dialectName)); | ||
var dialect = (Dialect)Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(dialectName)); | ||
dialect.Configure(props); | ||
return dialect; | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new HibernateException("Could not instantiate dialect class " + dialectName, e); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Configure the dialect. | ||
/// </summary> | ||
/// <param name="settings">The configuration settings.</param> | ||
public virtual void Configure(IDictionary<string, string> settings) | ||
{ | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a way to configure the dialect. |
||
|
||
#endregion | ||
|
||
#region Database type mapping support | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted for it to no more fail in case the driver could not be loaded.