Skip to content

Commit da97b4d

Browse files
committed
Allow conversions from decimal to double or float. Fixes #664
1 parent 0e65d53 commit da97b4d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/MySqlConnector/Core/Row.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,17 @@ public Stream GetStream(int ordinal)
299299
public double GetDouble(int ordinal)
300300
{
301301
var value = GetValue(ordinal);
302-
return value is float floatValue ? floatValue : (double) value;
302+
return value is float floatValue ? floatValue :
303+
value is decimal decimalValue ? (double) decimalValue :
304+
(double) value;
303305
}
304306

305-
public float GetFloat(int ordinal) => (float) GetValue(ordinal);
307+
public float GetFloat(int ordinal)
308+
{
309+
var value = GetValue(ordinal);
310+
return value is decimal decimalValue ? (float) decimalValue :
311+
(float) value;
312+
}
306313

307314
public MySqlDateTime GetMySqlDateTime(int ordinal)
308315
{

tests/Conformance.Tests/Conformance.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="AdoNet.Specification.Tests" Version="2.0.0-alpha4" />
13+
<PackageReference Include="AdoNet.Specification.Tests" Version="2.0.0-alpha5" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
1515
<PackageReference Include="xunit" Version="2.4.1" />
1616
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />

0 commit comments

Comments
 (0)