Details
-
Feature Request
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
None
-
undefined
-
NEW
-
NEW
Description
At the moment it's not possible to use variables coming from a different fact inside bindings, as in the following example
@Test public void testVariableInsideBinding() { String str = "import " + Person.class.getCanonicalName() + ";" + "import " + NameLengthCount.class.getCanonicalName() + ";" + "rule X when\n" + " $nlc : NameLengthCount() \n" + " Person ( $nameLength : $nlc.getNameLength(name))" + "then\n" + "end"; Results results = createKieBuilder(str ).getResults(); assertThat(results.getMessages(Message.Level.ERROR).stream().map(Message::getText)) .contains("Variables can not be used inside bindings. Variable [$nlc] is being used in binding '$nlc.getNameLength(name)'"); } public static class NameLengthCount { public int getNameLength(String name) { return name.length(); } }
That's because the variable binding is implemented with an InternalReadAccessor that takes only an object and not a whole tuple as input. It is required to refactor the InternalReadAccessor to work with a tuple (or to get rid of and workaround it if necessary) in order to allow this use case.
Attachments
Issue Links
- is related to
-
DROOLS-6552 Executable model doesn't provide error when using Variable inside bindings
- Closed