8000 cv api4 - Add support for more `where` operators by totten · Pull Request #184 · civicrm/cv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cv api4 - Add support for more where operators #184

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

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

totten
Copy link
Member
@totten totten commented Nov 16, 2023

Before:

The where shorthand (+w) supports some operators, like LIKE:

cv api4 Entity.get -T +w 'name LIKE Opti%' +s name

After:

The where shorthand (+w) supports more operators, like CONTAINS or REGEXP:

cv api4 Entity.get -T +w 'type CONTAINS ManagedEntity' +s name

cv api4 Entity.get -T +w 'name NOT REGEXP .*Field' +s name

@totten
Copy link
Member Author
totten commented Nov 17, 2023

Test was passing, except for some odd failures in 5.51,wp-demo,min. Probably unrelated, but will fire one more run.

@totten
Copy link
Member Author
totten commented Nov 17, 2023

civibot, test this please

@colemanw
Copy link
Member

@totten the full list of accepted operators can be obtained by calling \Civi\Api4\Utils\CoreUtil::getOperators()

@totten
Copy link
Member Author
totten commented Sep 12, 2024

Thanks, good point @colemanw. Updated to prefer a live list.

}));
}
else {
$this->operators = '\<=|\>=|=|!=|\<|\>|IS NULL|IS NOT NULL|IS EMPTY|IS NOT EMPTY|LIKE|NOT LIKE|IN|NOT IN|CONTAINS|NOT CONTAINS|REGEXP|NOT REGEXP|REGEXP BINARY|NOT REGEXP BINARY';
Copy link
Member

Choose a reason for hiding this comment

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

I mean, if you really wanna support < 5.30, then this list is a bit long. Those weren't all available at the time.

Copy link
Member Author
@totten totten Sep 13, 2024

Choose a reason for hiding this comment

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

Well... shrug. I just don't want the parser to crash where it was non-crashing before.

As to which operators work on which exact versions -- that's not really the concern of cv. The goal is to pass-through data to civicrm_api4() -- then civicrm_api4() can figure out whether it likes the request. (Same as with entity-names and action-names.) (The parser just has to be good enough to send in well-formed requests.)

@totten totten merged commit 598c076 into civicrm:master Sep 13, 2024
1 check passed
@totten totten deleted the master-api4-ops branch September 13, 2024 00:16
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
0