Skip to content

Commit

Permalink
fix for byte array types, with 0 length (defaults to longblob)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhemsley committed Apr 21, 2008
1 parent 65fea5c commit e82f7bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/core/Providers/TransformationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ protected IColumnPropertiesMapper GetColumnMapper(Column column)

if (column.Type == typeof(byte[]))
{
if (column.Size <= Convert.ToInt32(byte.MaxValue))
if (column.Size <= Convert.ToInt32(byte.MaxValue) && column.Size > 0)
return TypeToSqlProvider.Binary(Convert.ToByte(column.Size));
else if (column.Size <= Convert.ToInt32(ushort.MaxValue))
else if (column.Size <= Convert.ToInt32(ushort.MaxValue) && column.Size > 0)
return TypeToSqlProvider.Blob;
else
return TypeToSqlProvider.LongBlob;
Expand Down
6 changes: 6 additions & 0 deletions test/Providers/SqlServerTransformationProviderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ public void SetUp()
new Column("TestId", typeof(int)));
}

[Test]
public void ByteColumnWillBeCreatedAsBlob()
{
_provider.AddColumn("Test2", "BlobColumn", typeof(byte[]));
Assert.IsTrue(_provider.ColumnExists("Test2", "BlobColumn"));
}
}
}

0 comments on commit e82f7bc

Please sign in to comment.