Skip to content

Commit

Permalink
added LanguageID and ShopID in the "select" for the sql if they are n…
Browse files Browse the repository at this point in the history
…ot already added as either column mappings or conditionals.
  • Loading branch information
MatthiasSort committed Dec 22, 2023
1 parent 93fcafd commit 0f03324
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/EcomSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dynamicweb.DataIntegration.Integration.Interfaces;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;

Expand Down Expand Up @@ -52,6 +53,23 @@ protected string GetColumnsFromMappingConditions(HashSet<string> columnsToSkip)
return ret;
}

private string GetColumnsFromSettings()
{
string result = string.Empty;
string columnNameForLanguageId = MappingExtensions.GetLanguageIdColumnName(mapping.SourceTable.Name);
if (!string.IsNullOrEmpty(columnNameForLanguageId) && !IsColumnUsedInMappingConditions(columnNameForLanguageId) && !Columns.ContainsKey(columnNameForLanguageId.ToLower()))
{
result = $"[{columnNameForLanguageId}], ";
}

string columnNameForShopId = MappingExtensions.GetShopIdColumnName(mapping.SourceTable.Name);
if (!string.IsNullOrEmpty(columnNameForShopId) && !IsColumnUsedInMappingConditions(columnNameForShopId) && !Columns.ContainsKey(columnNameForShopId.ToLower()))
{
result += $"[{columnNameForShopId}], ";
}
return result;
}

protected bool IsColumnUsedInMappingConditions(string columnName)
{
return mapping.Conditionals.Any(mc => string.Compare(mc.SourceColumn?.Name, columnName, true) == 0);
Expand Down Expand Up @@ -482,6 +500,7 @@ protected override string GetColumns()
result += GetColumnsFromMappingConditions();
break;
}
result += GetColumnsFromSettings();
result = result.Substring(0, result.Length - 2);
return result;
}
Expand Down

0 comments on commit 0f03324

Please sign in to comment.