-
Notifications
You must be signed in to change notification settings - Fork 936
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-4088 - Dialect.GetCastTypeName is buggy #709
NH-4088 - Dialect.GetCastTypeName is buggy #709
Conversation
* Compare capacity against precision for precision based types * Fix dialects declarations for max precision * Fix dialects declarations for precision based types which were using length as precision or scale It is a prerequisite to the fix of GetTypeCastName.
* Use type length/precision/scale when defined * Use maximal capacity types otherwise when it makes sens * Use configurable default length/precision/scale otherwise
* Oracle double special case * More tests * Tests fixes
978e492
to
7b6ff8e
Compare
Assert.Ignore("Applies only to Firebird"); | ||
|
||
_driver = new FirebirdClientDriver(); | ||
_driver.Configure(cfg.Properties); |
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.
Test was failing due to used driver not being configured.
var expectedCommandTxt = "select (case when col = @p0 then cast(@p1 as VARCHAR(255)) else cast(@p2 as VARCHAR(255)) end) from table"; | ||
Assert.That(cmd.CommandText, Is.EqualTo(expectedCommandTxt)); | ||
var expectedCommandTxt = | ||
"select (case when col = @p0 then cast(@p1 as VARCHAR(4000)) else cast(@p2 as VARCHAR(4000)) end) from table"; |
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.
It was also failing because still testing for VARCHAR(255)
in resulting string, while the driver has been changed to use the default length instead of the supplied one for variable length string, due to the sql like
issue otherwise.
@@ -199,6 +199,9 @@ private static Dialect InstantiateDialect(string dialectName, IDictionary<string | |||
/// <param name="settings">The configuration settings.</param> | |||
public virtual void Configure(IDictionary<string, string> settings) | |||
{ | |||
DefaultCastLength = PropertiesHelper.GetInt32(Environment.QueryDefaultCastLength, settings, 4000); | |||
DefaultCastPrecision = PropertiesHelper.GetByte(Environment.QueryDefaultCastPrecision, settings, null) ?? 28; | |||
DefaultCastScale = PropertiesHelper.GetByte(Environment.QueryDefaultCastScale, settings, null) ?? 10; |
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.
There are some inconsistencies in those PropertiesHelper
methods.
I think the right signature is the GetInt32
one, but completed with an overload yielding a nullable and not taking any default.
@@ -215,17 +218,10 @@ public virtual string GetTypeName(SqlType sqlType) | |||
{ | |||
if (sqlType.LengthDefined || sqlType.PrecisionDefined || sqlType.ScaleDefined) | |||
{ | |||
string resultWithLength = _typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale); | |||
if (resultWithLength != null) return resultWithLength; | |||
return _typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale); |
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.
Those TypeNames
methods are never yielding null
. (Unless a Put
was done with null
, but now Put
throws null argument exception if it is attempted.)
@@ -64,7 +63,7 @@ public MySQLDialect() | |||
RegisterColumnType(DbType.String, 16777215, "MEDIUMTEXT"); | |||
//todo: future: add compatibility with decimal??? | |||
//An unpacked fixed-point number. Behaves like a CHAR column; | |||
//�unpacked� means the number is stored as a string, using one character for each digit of the value. | |||
//“unpacked” means the number is stored as a string, using one character for each digit of the value. |
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.
Encoding change. The file was not UTF-8.
} | ||
//Could not find a specific type for the capacity, using the default | ||
return Replace(Get(typecode), size, precision, scale); | ||
return Get(typecode); |
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 typenames are never supposed to have formatting placeholders.
NH-4088 - Dialect.GetCastTypeName is buggy
Fix TypeNames.Get for decimal capacity
Fix GetCastTypeName