On 11 Wrz, 04:31, "Ayende Rahien" <
aye...@ayende.com> wrote:
> I think you may want to set the length, since NH will automatically assign
> that, IIRC.
I tried setting length before, but I failed and didn't look much into
it.
Now I tested it more consistently and it actually helps for producing
the schema I want (and I don't need column element with sql-type
attribute), but not for the second problem.
I've found out that BinaryBlob is mapped to VARBINARY(n) or IMAGE
depending on specified length. If length is bigger than maximum for
VARBINARY, than it switches to IMAGE. It's consistent with e.g.
MsSql2005Dialect (where it switches to VARBINARY(MAX), since IMAGE is
deprecated), but I don't understand why it can't be IMAGE type all the
time (with length ignored), especially when there is a separate Binary
type in NH.
I think I have found a small problem with maximum for VARBINARY for
MsSqlCeDialect. Apparently it is set to 4000, however SQL Server CE
docs say it is 8000.
I created this test, based on what I found NH sources:
[Test]
public void BinaryBlob_mapping_to_SqlCe_types()
{
Dialect dialect = new MsSqlCeDialect();
SimpleValue sv = new SimpleValue();
sv.TypeName =
NHibernateUtil.BinaryBlob.Name;
Column column = new Column();
column.Value = sv;
// no length, should produce maximum
Assert.AreEqual("VARBINARY(8000)", column.GetSqlType(dialect, null));
// maximum varbinary length is 8000
column.Length = 8000;
Assert.AreEqual("VARBINARY(8000)", column.GetSqlType( dialect,
null));
column.Length = 8001;
Assert.AreEqual("IMAGE", column.GetSqlType( dialect, null));
}
First two asserts fail.
> Please create a test case for this if setting the length doesn't work.
I'm not sure how that test case would need to look like. I don't know
NH internals, so I really can't produce proper unit tests for this.
I can create something bigger, with separate hbm.xml mapping &
configuration file and code.
Would it be OK?
Thanks
Artur