Skip to content

Comments

[jpa] Support state filter when querying#19581

Merged
lsiepel merged 3 commits intoopenhab:mainfrom
ccutrer:jpa-query-state
Nov 15, 2025
Merged

[jpa] Support state filter when querying#19581
lsiepel merged 3 commits intoopenhab:mainfrom
ccutrer:jpa-query-state

Conversation

@ccutrer
Copy link
Member

@ccutrer ccutrer commented Oct 28, 2025

Depends on openhab/openhab-core#5106.

And since I'm using that, do some cleanup in all persistence services to use the newly-available Operator.getSymbol method when possible, as well as FilterCriteria.toString instead of custom implementations. They're used for debug logging, so the exact format changing shouldn't be important.

@ccutrer ccutrer added the awaiting other PR Depends on another PR label Oct 28, 2025
Signed-off-by: Cody Cutrer <cody@cutrer.us>
Also, FilterCriteria.toString instead of custom implementations. They're
only used for debug logging, so the exact format changing shouldn't
matter.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
@ccutrer ccutrer removed the awaiting other PR Depends on another PR label Oct 31, 2025
@ccutrer ccutrer marked this pull request as ready for review October 31, 2025 17:53
@ccutrer ccutrer requested review from a team, lujop and ssalonen as code owners October 31, 2025 17:53
lsiepel

This comment was marked as outdated.

@lsiepel lsiepel requested a review from Copilot November 15, 2025 11:42
@lsiepel lsiepel added the enhancement An enhancement or new feature for an existing add-on label Nov 15, 2025
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

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

Needs spotless, otherwise LGTM

This comment was marked as resolved.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@lsiepel lsiepel merged commit 7b474ff into openhab:main Nov 15, 2025
1 of 2 checks passed
@lsiepel lsiepel added this to the 5.1 milestone Nov 15, 2025
@ccutrer ccutrer deleted the jpa-query-state branch November 16, 2025 01:13
@lo92fr
Copy link
Contributor

lo92fr commented Nov 21, 2025

Hello all,

This PR seems to have broke the dynamoDb unit test ?
See : https://community.openhab.org/t/openhab-cloud-issue/167253/8
and : https://ci.openhab.org/job/openHAB-Addons/1970/testReport/

Laurent.

@lsiepel
Copy link
Contributor

lsiepel commented Nov 21, 2025

The core changes now point to the Operator class:

public enum Operator {
        EQ("="),
        NEQ("!="),
        GT(">"),
        LT("<"),
        GTE(">="),
        LTE("<=");

Looking at this PR again. It does not seem to match the implementation as it was for dynamodb: (especially NEQ) I think we need some override or custom replacement. Quick fix: filter.getOperator().getSymbol().replace("!=","<>")

private static String operatorAsString(Operator op) {
        switch (op) {
            case EQ:
                return "=";
            case NEQ:
                return "<>";
            case LT:
                return "<";
            case LTE:
                return "<=";
            case GT:
                return ">";
            case GTE:
                return ">=";

            default:
                throw new IllegalStateException("Unknown operator " + op);
        }
    }

@ccutrer
Copy link
Member Author

ccutrer commented Nov 21, 2025

🤦 I don't know how I overlooked that. I properly handled the same case for InfluxDB. I'm also surprised and confused how the build passed for this PR at all. I know I ran the tests locally too, but I was able to reproduce with the tests immediately today. 🤷. Regardless, #19680 is the fix.

@lsiepel
Copy link
Contributor

lsiepel commented Nov 21, 2025

I properly handled the same case for InfluxDB. I'm also surprised and confused how the build passed for this PR at all. I know

No worries, thanks for the quick fix!

@lo92fr
Copy link
Contributor

lo92fr commented Nov 21, 2025

Thanks for the fix @ccutrer.

I think build chain is a little misunderstanding in this case.
It put the build in state Unstable, but not failing clearly (that could be ok if only some test are failing).
And the other build continue to work as if everything where ok (at least on Jenkins side), but not getting the latest artifacts.
Don't look if error was more clear on Github actions side, but not really sure.
Perhaps something that can be enhance in future to help prevent this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants