|
From: <fab...@us...> - 2009-06-14 23:29:27
|
Revision: 4471
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4471&view=rev
Author: fabiomaulo
Date: 2009-06-14 23:28:27 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
Fix NH-1835
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs
trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs 2009-06-14 21:09:52 UTC (rev 4470)
+++ trunk/nhibernate/src/NHibernate/Type/BinaryBlobType.cs 2009-06-14 23:28:27 UTC (rev 4471)
@@ -15,6 +15,7 @@
public class BinaryBlobType : BinaryType
{
internal BinaryBlobType(): base(new BinaryBlobSqlType()) {}
+ internal BinaryBlobType(BinarySqlType sqlType) : base(sqlType) {}
/// <summary></summary>
public override string Name
Modified: trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 21:09:52 UTC (rev 4470)
+++ trunk/nhibernate/src/NHibernate/Type/TypeFactory.cs 2009-06-14 23:28:27 UTC (rev 4471)
@@ -69,7 +69,7 @@
private static readonly IDictionary<string, GetNullableTypeWithPrecision> getTypeDelegatesWithPrecision =
new ThreadSafeDictionary<string, GetNullableTypeWithPrecision>(new Dictionary<string, GetNullableTypeWithPrecision>());
- private delegate NullableType GetNullableTypeWithLength(int length);
+ private delegate NullableType GetNullableTypeWithLength(int length); // Func<int, NullableType>
private delegate NullableType GetNullableTypeWithPrecision(byte precision, byte scale);
@@ -176,8 +176,12 @@
typeByTypeOfName["yes_no"] = NHibernateUtil.YesNo;
- getTypeDelegatesWithLength.Add(NHibernateUtil.Binary.Name, GetBinaryType);
- getTypeDelegatesWithLength.Add(NHibernateUtil.BinaryBlob.Name, GetBinaryType);
+ getTypeDelegatesWithLength.Add(NHibernateUtil.Binary.Name,
+ l =>
+ GetType(NHibernateUtil.Binary, l, len => new BinaryType(SqlTypeFactory.GetBinary(len))));
+ getTypeDelegatesWithLength.Add(NHibernateUtil.BinaryBlob.Name,
+ l =>
+ GetType(NHibernateUtil.BinaryBlob, l, len => new BinaryBlobType(SqlTypeFactory.GetBinaryBlob(len))));
getTypeDelegatesWithLength.Add(NHibernateUtil.Serializable.Name, GetSerializableType);
getTypeDelegatesWithLength.Add(NHibernateUtil.String.Name, GetStringType);
getTypeDelegatesWithLength.Add(NHibernateUtil.StringClob.Name, GetStringType);
@@ -520,6 +524,19 @@
return (NullableType)returnType;
}
+ private static NullableType GetType(NullableType defaultUnqualifiedType, int length, GetNullableTypeWithLength ctorDelegate)
+ {
+ string key = GetKeyForLengthBased(defaultUnqualifiedType.Name, length);
+ IType returnType;
+ if (!typeByTypeOfName.TryGetValue(key, out returnType))
+ {
+ returnType = ctorDelegate(length);
+ AddToTypeOfNameWithLength(key, returnType);
+ }
+
+ return (NullableType)returnType;
+ }
+
private static NullableType GetType(NullableType defaultUnqualifiedType, byte precision, byte scale, NullableTypeCreatorDelegate ctor)
{
string key = GetKeyForPrecisionScaleBased(defaultUnqualifiedType.Name, precision, scale);
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs 2009-06-14 21:09:52 UTC (rev 4470)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs 2009-06-14 23:28:27 UTC (rev 4471)
@@ -1,16 +1,17 @@
using NUnit.Framework;
+using NHibernate.SqlTypes;
namespace NHibernate.Test.NHSpecificTest.NH1835
{
[TestFixture]
public class Fixture: BugTestCase
{
- [Test, Ignore("Not fixed yet.")]
+ [Test]
public void ColumnTypeBinaryBlob()
{
var pc = sessions.GetEntityPersister(typeof (Document).FullName);
var type = pc.GetPropertyType("Contents");
- Assert.That(type.SqlTypes(sessions)[0].Length, Is.EqualTo(3000));
+ Assert.That(type.SqlTypes(sessions)[0], Is.InstanceOf<BinaryBlobSqlType>());
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml 2009-06-14 21:09:52 UTC (rev 4470)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml 2009-06-14 23:28:27 UTC (rev 4471)
@@ -7,8 +7,6 @@
<id name="Id">
<generator class="guid.comb" />
</id>
- <property name="Contents">
- <column name="Contents" sql-type="varbinary(3000)"/>
- </property>
+ <property name="Contents" type="BinaryBlob(3000)"/>
</class>
</hibernate-mapping>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|