Skip to content

Commit

Permalink
Fixed allowing implicit decimal conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Aug 24, 2024
1 parent 86e688e commit 7ce905b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MarkMpn.Sql4Cds.Engine/ExecutionPlan/FoldableJoinNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private bool FoldFetchXmlJoin(NodeCompilationContext context, IList<OptimizerHin
.GetLinkEntities()
.Where(le => le.Items != null)
.SelectMany(le => le.Items.OfType<FetchAttributeType>())
.Concat(leftFetch.Entity?.Items.OfType<FetchAttributeType>() ?? Enumerable.Empty<FetchAttributeType>())
.Concat(leftFetch.Entity.Items?.OfType<FetchAttributeType>() ?? Enumerable.Empty<FetchAttributeType>())
.Select(a => a.alias)
.Where(alias => alias != null)
.Intersect(
Expand Down
8 changes: 4 additions & 4 deletions MarkMpn.Sql4Cds.Engine/ExecutionPlan/SqlTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ public static bool CanChangeTypeImplicit(DataTypeReference from, DataTypeReferen

var toType = toSql.SqlDataTypeOption;

// Any numeric type can be implicitly converted to any other.
if (fromType.IsNumeric() && toType.IsNumeric())
return true;

if (Array.IndexOf(_precendenceOrder, fromType) == -1 ||
Array.IndexOf(_precendenceOrder, toType) == -1)
return false;
Expand All @@ -390,10 +394,6 @@ public static bool CanChangeTypeImplicit(DataTypeReference from, DataTypeReferen
if (fromType.IsStringType() || toType.IsStringType())
return true;

// Any numeric type can be implicitly converted to any other.
if (fromType.IsNumeric() && toType.IsNumeric())
return true;

// Any numeric type can be implicitly converted to datetime
if (fromType.IsNumeric() && (toType == SqlDataTypeOption.DateTime || toType == SqlDataTypeOption.SmallDateTime))
return true;
Expand Down

0 comments on commit 7ce905b

Please sign in to comment.