-
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
NH-4062 - Oracle Unicode support dual model. #667
Conversation
fc66069
to
cdf4d5d
Compare
[Explicit] | ||
public void NoBooleanParameters() | ||
[Theory] | ||
public void NoBooleanParameters(bool managed) |
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.
@@ -772,7 +772,7 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
/// <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 comment
The reason will be displayed to describe this comment to others. Learn more.
Added a way to configure the dialect.
/// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
New setting just for Oracle.
base.Configure(settings); | ||
|
||
// If changing the default value, keep it in sync with Oracle8iDialect.Configure. | ||
UseNPrefixedTypesForUnicode = PropertiesHelper.GetBoolean(Cfg.Environment.OracleUseNPrefixedTypesForUnicode, settings, false); |
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.
Default value false
avoid a possible breaking change for queries, by keeping the default typing of the ODP.Net provider.
cdf4d5d
to
56ec0f2
Compare
56ec0f2
to
d5e54db
Compare
|
||
// If changing the default value, keep it in sync with OracleDataClientDriverBase.Configure. | ||
UseNPrefixedTypesForUnicode = PropertiesHelper.GetBoolean(Environment.OracleUseNPrefixedTypesForUnicode, settings, false); | ||
RegisterCharacterTypeMappings(); |
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.
(Moving the comment on non-outdated file version.)
Possible breaking change for those using hbm2ddl: now Unicode string types will be mapped by default to non N
prefixed types, while NH 4 was mapping to N
prefixed one.
Doing it the other way round would be a possible breaking change for queries instead, because they would start using NVarchar2
for Unicode string parameters instead of Varchar2
(NH 4 currently maps that to Varchar2
).
Other possible breaking change, character types will not be registered if the dialect is not configured, which may happen if not getting it through Dialect.GetDialect
.
3a0489d
to
9b72bef
Compare
78f63cb
to
006caa7
Compare
Rebased with async regeneration embedded in "NH-4062 - Oracle Unicode support dual model." commit. (It does just alter one async test.) |
/// </exception> | ||
protected OracleDataClientDriverBase(bool managed) | ||
: this( | ||
managed ? _managedProviderInvariantName : _unmanagedProviderInvariantName, |
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.
Can we move these back to the constructor instead?
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.
I do not get it.
Would you like this to be removed and having manage and un-managed classes providing these values themselves? Or should the ReflectionBasedDriver
be changed for allowing specifying these values without a constructor call (which forces to put that inside : this(...)
or : base(...)
), by example with some protected settable properties or a protected initialize method?
Or something else?
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.
What I meant is to receive these strings from the child constructor instead of a bool argument. Eg. move this constructor down the inheritance chain:
public OracleManagedDataClientDriver : base(_managedProviderInvariantName, ...)
Also, it seems that we need to have only 2 variable strings: "Oracle.ManagedDataAccess" and "Oracle.DataAccess", all other are derivatives
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.
Done, with only assembly name as a parameter. My previous idea was to be able to adapt to eventual weird naming changes done on Oracle side for some future version. But well, they may not do same than Sap with its Sybase drivers.
006caa7
to
bec901a
Compare
|
||
var prefix = UseNPrefixedTypesForUnicode ? "N" : string.Empty; | ||
RegisterColumnType(DbType.StringFixedLength, prefix + "CHAR(255)"); | ||
RegisterColumnType(DbType.StringFixedLength, 2000, prefix + "CHAR($l)"); |
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.
Not sure why this is 2000.
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.
Well me too... I am not sufficiently experimented with Oracle for knowing of any past reason, whether this should be overridden in newer dialects or not, ... So I have just kept the previous value.
_oracleCommandBindByName = oracleCommandType.GetProperty("BindByName"); | ||
|
||
var parameterType = ReflectHelper.TypeFromAssembly(clientNamespace + ".OracleParameter", driverAssemblyName, true); | ||
_oracleDbType = parameterType.GetProperty("OracleDbType"); |
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.
Can we build delegates for these properties? Like in MySqlClientSqlCommandSet
?
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.
I forgot about it, you are right.
bec901a
to
f0b8f34
Compare
_commandBindByNameSetter = DelegateHelper.BuildPropertySetter<bool>(oracleCommandType, "BindByName"); | ||
|
||
var parameterType = ReflectHelper.TypeFromAssembly(clientNamespace + ".OracleParameter", driverAssemblyName, true); | ||
_parameterOracleDbTypeSetter = DelegateHelper.BuildPropertySetter<object>(parameterType, "OracleDbType"); |
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.
We can not use the actual set type here for the delegate. This has required adapting DelegateHelper
.
var valueParameter = Expression.Parameter(typeof (T), "value"); | ||
Expression value = valueParameter; | ||
// Cast value if required | ||
if (!property.Type.IsAssignableFrom(typeof(T))) |
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.
Changes required for supporting setting without being able to provide the actual property type as a generic parameter.
e5701dc
to
4bf7d13
Compare
4bf7d13
to
8ee4c72
Compare
NH-4062 - Properly handle Oracle Unicode support dual model
And reverting NH-3620: this was a workaround for a now obsolete bug in ODP.Net managed driver. Its test still pass without it now. It should probably have been solved as "external issue" with instruction on how to extend the driver for working around the bug till Oracle fixes it.Removing this workaround causes another test to fail:BinaryBlobTypeFixture.ReadWriteZeroLen
. Without it, the blob come back asnull
.Managed and un-managed drivers require the same code, but it was duplicated. Now it is refactored in a single base class.