Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-drools-6010] Date Between Dates with globals Not Trigg… #6011

Merged

Conversation

tkobayas
Copy link
Contributor

@tkobayas tkobayas commented Jul 5, 2024

Comment on lines +135 to +137
if (!(this.identifier.equals(other.identifier))) {
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this check, ConstraintEvaluator.replaceDeclaration considers that GlobalExtractor for $startDate and GlobalExtractor for $endDate are the same.

@tkobayas tkobayas linked an issue Jul 5, 2024 that may be closed by this pull request
}

@Test
public void dateBetweenVariables() throws ParseException {
Copy link
Contributor Author

@tkobayas tkobayas Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test (not using globals) doesn't have the issue, because resolver.getDeclaration() returns the same Declaration object, so replaceDeclaration() is not called.

https://github.com/apache/incubator-kie-drools/blob/main/drools-base/src/main/java/org/drools/base/rule/LogicTransformer.java#L253-L270

    private void replaceDeclarations( DeclarationScopeResolver resolver, Pattern pattern, Constraint constraint ) {
        Declaration[] decl = constraint.getRequiredDeclarations();
        for ( Declaration aDecl : decl ) {
            Declaration resolved = resolver.getDeclaration( aDecl.getIdentifier() );

            if ( constraint instanceof IndexableConstraint && ( (IndexableConstraint) constraint ).isUnification() ) {
                if ( ClassObjectType.DroolsQuery_ObjectType.isAssignableFrom( resolved.getPattern().getObjectType() ) ) {
                    Declaration redeclaredDeclr = new Declaration( resolved.getIdentifier(), ( (IndexableConstraint) constraint ).getFieldExtractor(), pattern, false );
                    pattern.addDeclaration( redeclaredDeclr );
                } else if ( resolved.getPattern() != pattern ) {
                    ( (IndexableConstraint ) constraint ).unsetUnification();
                }
            }

            if ( resolved != null && resolved != aDecl && resolved.getPattern() != pattern ) {
                constraint.replaceDeclaration( aDecl,
                                               resolved );
            } else if ( resolved == null ) {

@tkobayas tkobayas marked this pull request as ready for review July 8, 2024 01:51
@tkobayas
Copy link
Contributor Author

tkobayas commented Jul 8, 2024

GHA kogito-apps : not related to this PR

2024-07-08T03:44:08.0996602Z [ERROR] Caused by: java.util.concurrent.ExecutionException: com.google.cloud.tools.jib.http.ResponseException: 504 Gateway Time-out
2024-07-08T03:44:08.0997660Z [ERROR] GET https://registry.access.redhat.com/v2/ubi8/openjdk-17-runtime/manifests/1.18

GHA kogito-quarkus-examples : not related to this PR

2024-07-08T02:35:50.1018392Z [ERROR] Caused by: java.util.concurrent.ExecutionException: com.google.cloud.tools.jib.http.ResponseException: 504 Gateway Time-out
2024-07-08T02:35:50.1020052Z [ERROR] GET https://registry.access.redhat.com/v2/ubi8/openjdk-17-runtime/manifests/1.18

@tkobayas
Copy link
Contributor Author

tkobayas commented Jul 8, 2024

@mariofusco @lucamolteni @pibizza Please review, thanks!

@mariofusco mariofusco merged commit 8b8e8b9 into apache:main Jul 8, 2024
17 of 19 checks passed
rgdoliveira pushed a commit to rgdoliveira/drools that referenced this pull request Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date Between Dates with globals Not Triggering for Executable Model
3 participants