You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "bncriju (via GitHub)" <gi...@apache.org> on 2024/08/01 10:34:05 UTC
[PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
bncriju opened a new pull request, #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040
Fixes https://github.com/apache/incubator-kie-issues/issues/1345
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700221583
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
+ nullObject.add(null);
+ nullObject.add(null);
+ nullObject.add(null);
final Object[][] cases = new Object[][] {
//normal:
{"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null},
- {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", nullObject, FEELEvent.Severity.ERROR},
Review Comment:
@gitgabrio No, my question wasn't clear, sorry.
The point is:
The `"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1"` expression returns a List (null, null, null), but I expected to have a single null here, and not a List of nulls. Is that correct?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700221583
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
+ nullObject.add(null);
+ nullObject.add(null);
+ nullObject.add(null);
final Object[][] cases = new Object[][] {
//normal:
{"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null},
- {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", nullObject, FEELEvent.Severity.ERROR},
Review Comment:
@gitgabrio No, my question wasn't clear, sorry.
The point is:
The `"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1"` expression returns a List `(null, null, null)`, but I expected to have a single `null` here, and not a List of nulls. Is that correct?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700261414
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
Review Comment:
@bncriju
Sorry for late review, but could you pls remove this
`List<Integer> nullObject = new ArrayList<>();`
and follow the same approach we did elsewhere (i.e.
`Stream.of(null, null, null)` inside the test itself)
Beside: `nullObject` is an extemely misleading term, because
1. this is not a generic object, but a List
2. this is not a `null` `Object`, but a `List` filled with `null`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700062055
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
+ nullObject.add(null);
+ nullObject.add(null);
+ nullObject.add(null);
final Object[][] cases = new Object[][] {
//normal:
{"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null},
- {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", nullObject, FEELEvent.Severity.ERROR},
Review Comment:
@gitgabrio Is it expected this test case returns a List of null? WDYT?
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java:
##########
@@ -51,6 +51,8 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
private static Collection<Object[]> data() {
final Object[][] cases = new Object[][] {
// date/time/duration function invocations
+ { "@\"2021-01-01\" + 10", null , FEELEvent.Severity.ERROR},
+ { "@\"2021-01-01T10:10:10\" + 10", null , FEELEvent.Severity.ERROR},
Review Comment:
@bncriju Can you please add here those additional test cases:
- number + Date
- number + DateTime
- number - Date
- number - DateTime
- Date - number
- DateTime - number
They should all return null with an error.
Just for the sake of completeness :)
Thank you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700269724
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
+ nullObject.add(null);
+ nullObject.add(null);
+ nullObject.add(null);
final Object[][] cases = new Object[][] {
//normal:
{"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null},
- {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", nullObject, FEELEvent.Severity.ERROR},
Review Comment:
@yesamer
The `for x....` iterates over all the elements, and for each element the `+1` is executed.
Since the `date + number` operation returns `null`, every single iteration is mapped to `null`.
So, I'm expecting to have a list of `null`
Very similar to `stream.map`: does this make sense ? Am I clear ?
Please, correct me if I'm wrong
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700288774
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
+ nullObject.add(null);
+ nullObject.add(null);
+ nullObject.add(null);
final Object[][] cases = new Object[][] {
//normal:
{"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null},
- {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", nullObject, FEELEvent.Severity.ERROR},
Review Comment:
@gitgabrio Yes it makes sense, is not the `for` expression that is wrong but its internal statement. Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700366832
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELDateTimeDurationTest.java:
##########
@@ -51,6 +51,8 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
private static Collection<Object[]> data() {
final Object[][] cases = new Object[][] {
// date/time/duration function invocations
+ { "@\"2021-01-01\" + 10", null , FEELEvent.Severity.ERROR},
+ { "@\"2021-01-01T10:10:10\" + 10", null , FEELEvent.Severity.ERROR},
Review Comment:
@bncriju Don't forget this please :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio merged PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [Incubator-kie-issues#1345] It shouldn't be possible to add\subtract a DateTime with a number [incubator-kie-drools]
Posted by "gitgabrio (via GitHub)" <gi...@apache.org>.
gitgabrio commented on code in PR #6040:
URL: https://github.com/apache/incubator-kie-drools/pull/6040#discussion_r1700203144
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEEL12ExtendedForLoopTest.java:
##########
@@ -45,10 +45,15 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
}
private static Collection<Object[]> data() {
+ List<Integer> nullObject = new ArrayList<>();
+ nullObject.add(null);
+ nullObject.add(null);
+ nullObject.add(null);
final Object[][] cases = new Object[][] {
//normal:
{"for x in [1, 2, 3] return x+1", Stream.of(1, 2, 3 ).map(x -> BigDecimal.valueOf(x + 1 ) ).collect(Collectors.toList() ), null},
- {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x + @\"P1D\"", Stream.of("2021-01-02", "2021-01-03", "2021-01-04" ).map(LocalDate::parse).collect(Collectors.toList() ), null},
+ {"for x in @\"2021-01-01\"..@\"2021-01-03\" return x+1", nullObject, FEELEvent.Severity.ERROR},
Review Comment:
@yesamer Because with the removal of that
```java
if (right instanceof BigDecimal bigDecimal) {
Period toAdd = Period.ofDays(bigDecimal.intValue());
return temporal.plus(toAdd);
}
```
the case "date + number" is unmanaged, and the evaluation returns `null` - if this was your question.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org