Skip to content

Commit

Permalink
Merge branch 'snowflakedb#81' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilkka Kudjoi committed Oct 23, 2018
2 parents 48bf593 + 985e57a commit 7061daf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Snowflake.Data/Core/SFDataConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System;
using System.ComponentModel;
using System.Data;
using System.Globalization;
using System.Text;
using System.Threading;
using Snowflake.Data.Log;
using Snowflake.Data.Client;

Expand Down Expand Up @@ -39,6 +41,7 @@ internal static object ConvertToCSharpVal(string srcVal, SFDataType srcType, Typ
|| destType == typeof(float)
|| destType == typeof(decimal))
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
var typeConverter = TypeDescriptor.GetConverter(destType);
return typeConverter.ConvertFrom(srcVal);
}
Expand Down Expand Up @@ -140,8 +143,9 @@ internal static Tuple<string, string> csharpTypeValToSfTypeVal(DbType srcType, o
{
string destType;
string destVal;
var srcValAsCultureInvariantString = string.Format(CultureInfo.InvariantCulture, "{0}", srcVal);

switch(srcType)
switch (srcType)
{
case DbType.Decimal:
case DbType.Int16:
Expand All @@ -152,24 +156,24 @@ internal static Tuple<string, string> csharpTypeValToSfTypeVal(DbType srcType, o
case DbType.UInt64:
case DbType.VarNumeric:
destType = SFDataType.FIXED.ToString();
destVal = srcVal.ToString();
destVal = srcValAsCultureInvariantString;
break;

case DbType.Boolean:
destType = SFDataType.BOOLEAN.ToString();
destVal = srcVal.ToString();
destVal = srcValAsCultureInvariantString;
break;

case DbType.Double:
destType = SFDataType.REAL.ToString();
destVal = srcVal.ToString();
destVal = srcValAsCultureInvariantString;
break;

case DbType.Guid:
case DbType.String:
case DbType.StringFixedLength:
destType = SFDataType.TEXT.ToString();
destVal = srcVal.ToString();
destVal = srcValAsCultureInvariantString;
break;

case DbType.Date:
Expand Down

0 comments on commit 7061daf

Please sign in to comment.