Skip to content

Commit

Permalink
Remove the need to specify the original type of the column to be tran…
Browse files Browse the repository at this point in the history
…sformed
  • Loading branch information
Cédric L. Charlier committed Apr 13, 2019
1 parent 1145615 commit ff7a29b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
15 changes: 3 additions & 12 deletions NBi.Core/Calculation/BasePredicateFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,9 @@ protected object EvaluateExpression(IColumnExpression expression, DataRow row)

foreach (var nativeFunction in parse.Skip(1))
{
var info = new TransformationInfo()
{
OriginalType = expression.Type,
Language = expression.Language,
Code = nativeFunction,
};

var factory = new TransformerFactory();
var transformer = factory.Instantiate(info);

transformer.Initialize(info.Code);
value = transformer.Execute(value);
var factory = new NativeTransformationFactory();
var transformer = factory.Instantiate(nativeFunction);
value = transformer.Evaluate(value);
}

return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@
</no-rows>
</assert>
</test>
<test name="Single-row with dateTime informations using an expression based on native functions" uid="0140">
<test name="all-rows with dateTime informations using an expression based on native functions" uid="0140">
<system-under-test>
<execution>
<query
Expand All @@ -696,12 +696,12 @@
</system-under-test>
<assert>
<all-rows>
<expression name="createdTime" original-type="dateTime">
<expression name="createdTime">
<script language="native">
[B] | utc-to-local(Brussels)
</script>
</expression>
<expression name="deadLine" original-type="dateTime">
<expression name="deadLine">
<script language="native">
[A] | utc-to-local(Brussels) | dateTime-to-date | dateTime-to-previous-day | dateTime-to-set-time(07:00:00)
</script>
Expand Down
2 changes: 1 addition & 1 deletion NBi.Testing/Unit/Xml/Constraints/EvaluateRowsXmlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void Deserialize_SampleFile_Expression()
Assert.That(ctr.Expressions, Has.Count.EqualTo(1));
Assert.That(ctr.Expressions[0].Value, Is.EqualTo("= OrderQuantity*(UnitPrice-(UnitPrice*UnitDiscount))"));
Assert.That(ctr.Expressions[0].Column, Is.EqualTo(5));
//Assert.That(ctr.Expressions[0].Type, Is.EqualTo(ColumnType.Numeric));
Assert.That(ctr.Expressions[0].Type, Is.EqualTo(ColumnType.Numeric));
Assert.That(ctr.Expressions[0].Tolerance, Is.EqualTo("0.01"));
}
}
Expand Down
4 changes: 2 additions & 2 deletions NBi.Xml/Items/Calculation/ExpressionXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public LanguageType Language
[DefaultValue(0)]
public int Column { get; set; }

[XmlAttribute("original-type")]
[DefaultValue(ColumnType.Numeric)]
[XmlAttribute("type")]
[DefaultValue(ColumnType.Text)]
public ColumnType Type { get; set; }

[XmlAttribute("tolerance")]
Expand Down
1 change: 0 additions & 1 deletion NBi.Xml/Schema/BaseType.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,6 @@
<xs:element name="script" type="script-type" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="original-type" type="column-type-enum" use="optional"/>
</xs:complexType>
<xs:complexType name="predicate-type">
<xs:choice>
Expand Down

0 comments on commit ff7a29b

Please sign in to comment.