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

PackageQuery: filter_nevra to accept more comparators #276

Merged
merged 2 commits into from
Feb 13, 2023

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Feb 9, 2023

Current implementation of filter_nevra(PackageSet) accepts only EQ and NEQ comparators.
This change enhances this filter to accept also GT, GTE, LT, and LTE comparators.

libdnf_throw_assert_unsupported_query_cmp_type(cmp_type);
libdnf_assert_same_base(p_impl->base, package_set.get_base());

bool cmp_not = (cmp_type & libdnf::sack::QueryCmp::NOT) == libdnf::sack::QueryCmp::NOT;
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor - to ensure that there is not GT + NOT (or similar) as comperator I would suggest to change the test:

bool cmp_not = (cmp_type == libdnf::sack::QueryCmp::NEQ);
if (cmp_not) {
    cmp_type = libdnf::sack::QueryCmp::EQ;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I plan to use LTE + NOT in list command implementation. Let me improve the description of the function.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've rephrased the doc string of filter_nevra(PackageSet) filter.

Current implementation of filter_nevra(PackageSet) accepts only EQ and
NEQ comparators.
This change enhances this filter to accept also GT, GTE, LT, and LTE
comparators.
@m-blaha m-blaha force-pushed the mblaha/filter_nevra branch from c53642c to d95e627 Compare February 10, 2023 10:24
Copy link
Contributor

@j-mracek j-mracek left a comment

Choose a reason for hiding this comment

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

LGTM

@j-mracek j-mracek merged commit 2788548 into main Feb 13, 2023
@j-mracek j-mracek deleted the mblaha/filter_nevra branch February 13, 2023 15:39
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.

2 participants