mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Fix: GUIDs not being stored as Guids (#461)
* Fixing issue where Guids weren't being stored in the service buffer file as Guids * Removing unnecessary ReadSqlGuid method * Adding unit test for revert cell integration * Adding unit test for edit session initialization * Revert "Adding unit test for revert cell integration" This reverts commit a949926f2ebbb0c39f776edba76d999af4f3f3e9. * Revert "Adding unit test for edit session initialization" This reverts commit ff9e5a7d0e5392b27257e57db64879699d73d21c.
This commit is contained in:
@@ -81,6 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
|||||||
{typeof(DateTimeOffset), (o, id, col) => ReadDateTimeOffset(o, id)},
|
{typeof(DateTimeOffset), (o, id, col) => ReadDateTimeOffset(o, id)},
|
||||||
{typeof(TimeSpan), (o, id, col) => ReadTimeSpan(o, id)},
|
{typeof(TimeSpan), (o, id, col) => ReadTimeSpan(o, id)},
|
||||||
{typeof(byte[]), (o, id, col) => ReadBytes(o, id)},
|
{typeof(byte[]), (o, id, col) => ReadBytes(o, id)},
|
||||||
|
{typeof(Guid), (o, id, col) => ReadGuid(o, id)},
|
||||||
|
|
||||||
{typeof(SqlString), (o, id, col) => ReadString(o, id)},
|
{typeof(SqlString), (o, id, col) => ReadString(o, id)},
|
||||||
{typeof(SqlInt16), (o, id, col) => ReadInt16(o, id)},
|
{typeof(SqlInt16), (o, id, col) => ReadInt16(o, id)},
|
||||||
@@ -467,14 +468,14 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="offset">Offset into the file to read the bytes from</param>
|
/// <param name="offset">Offset into the file to read the bytes from</param>
|
||||||
/// <param name="rowId">Internal ID of the row that will be stored in the cell</param>
|
/// <param name="rowId">Internal ID of the row that will be stored in the cell</param>
|
||||||
/// <returns>A guid type object</returns>
|
/// <returns>A system guid type object</returns>
|
||||||
internal FileStreamReadResult ReadGuid(long offset, long rowId)
|
internal FileStreamReadResult ReadGuid(long offset, long rowId)
|
||||||
{
|
{
|
||||||
return ReadCellHelper(offset, rowId, length =>
|
return ReadCellHelper(offset, rowId, length =>
|
||||||
{
|
{
|
||||||
byte[] output = new byte[length];
|
byte[] output = new byte[length];
|
||||||
Buffer.BlockCopy(buffer, 0, output, 0, length);
|
Buffer.BlockCopy(buffer, 0, output, 0, length);
|
||||||
return new SqlGuid(output);
|
return new Guid(output);
|
||||||
}, totalLength => totalLength == 1);
|
}, totalLength => totalLength == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.DataStorage
|
|||||||
{typeof(DateTimeOffset), val => WriteDateTimeOffset((DateTimeOffset) val) },
|
{typeof(DateTimeOffset), val => WriteDateTimeOffset((DateTimeOffset) val) },
|
||||||
{typeof(TimeSpan), val => WriteTimeSpan((TimeSpan) val) },
|
{typeof(TimeSpan), val => WriteTimeSpan((TimeSpan) val) },
|
||||||
{typeof(byte[]), val => WriteBytes((byte[]) val)},
|
{typeof(byte[]), val => WriteBytes((byte[]) val)},
|
||||||
|
{typeof(Guid), val => WriteGuid((Guid) val)},
|
||||||
|
|
||||||
{typeof(SqlString), val => WriteNullable((SqlString) val, obj => WriteString((string) obj))},
|
{typeof(SqlString), val => WriteNullable((SqlString) val, obj => WriteString((string) obj))},
|
||||||
{typeof(SqlInt16), val => WriteNullable((SqlInt16) val, obj => WriteInt16((short) obj))},
|
{typeof(SqlInt16), val => WriteNullable((SqlInt16) val, obj => WriteInt16((short) obj))},
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using Xunit;
|
|||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.DataStorage
|
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.DataStorage
|
||||||
{
|
{
|
||||||
public class ReaderWriterPairTest
|
public class ServiceBufferReaderWriterTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ReaderStreamNull()
|
public void ReaderStreamNull()
|
||||||
@@ -535,23 +535,25 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.DataStorage
|
|||||||
(reader, rowId) => reader.ReadBytes(0, rowId));
|
(reader, rowId) => reader.ReadBytes(0, rowId));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
public static IEnumerable<object[]> GuidTestParameters
|
||||||
public void GuidTest()
|
|
||||||
{
|
{
|
||||||
// Setup:
|
get
|
||||||
// ... Create some test values
|
|
||||||
// NOTE: We are doing these here instead of InlineData because Guid type can't be written as constant expressions
|
|
||||||
Guid[] guids =
|
|
||||||
{
|
{
|
||||||
Guid.Empty, Guid.NewGuid(), Guid.NewGuid()
|
yield return new object[] {Guid.Empty};
|
||||||
};
|
yield return new object[] {Guid.NewGuid()};
|
||||||
foreach (Guid guid in guids)
|
yield return new object[] {Guid.NewGuid()};
|
||||||
{
|
|
||||||
VerifyReadWrite(guid.ToByteArray().Length + 1, new SqlGuid(guid), (writer, val) => writer.WriteGuid(guid),
|
|
||||||
(reader, rowId) => reader.ReadGuid(0, rowId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[MemberData(nameof(GuidTestParameters))]
|
||||||
|
public void GuidTest(Guid testValue)
|
||||||
|
{
|
||||||
|
VerifyReadWrite(testValue.ToByteArray().Length + 1, testValue,
|
||||||
|
(writer, val) => writer.WriteGuid(testValue),
|
||||||
|
(reader, rowId) => reader.ReadGuid(0, rowId));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void MoneyTest()
|
public void MoneyTest()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user