Skip to content

Commit 08557fe

Browse files
committed
Проверка имен колонок в правилах сортировки
1 parent 1a6e120 commit 08557fe

File tree

1 file changed

+10
-5
lines changed
  • src/OneScript.StandardLibrary/Collections/ValueTable

1 file changed

+10
-5
lines changed

src/OneScript.StandardLibrary/Collections/ValueTable/ValueTable.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This Source Code Form is subject to the terms of the
1717
using ScriptEngine.Machine.Contexts;
1818
using System;
1919
using System.Collections.Generic;
20+
using System.Data.Common;
2021
using System.Linq;
2122

2223
namespace OneScript.StandardLibrary.Collections.ValueTable
@@ -648,15 +649,19 @@ private List<ValueTableSortRule> GetSortRules(string Columns)
648649
if (description.Length == 0)
649650
throw ColumnException.WrongColumnName();
650651
if (description.Length > 2)
651-
throw RuntimeException.InvalidNthArgumentValue(1);
652-
653-
var Desc = new ValueTableSortRule
652+
throw RuntimeException.InvalidNthArgumentValue(1);
653+
654+
var sortColumn = this.Columns.FindColumnByName(description[0]);
655+
if (sortColumn == null)
656+
throw ColumnException.WrongColumnName(description[0]);
657+
658+
var rule = new ValueTableSortRule
654659
{
655-
Column = this.Columns.FindColumnByName(description[0]),
660+
Column = sortColumn,
656661
direction = (description.Length > 1 && description[1].BilingualEquals("УБЫВ", "DESC")) ? -1 : 1
657662
};
658663

659-
Rules.Add(Desc);
664+
Rules.Add(rule);
660665
}
661666

662667
return Rules;

0 commit comments

Comments
 (0)