-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Add New API Call To Get All Unique Fields For Given Entity #11990
Add New API Call To Get All Unique Fields For Given Entity #11990
Conversation
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic looks good, just make sure you're following these guidelines:
https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
api/v3/Generic/Getunique.php
Outdated
* | ||
* @return mixed | ||
*/ | ||
function civicrm_api3_generic_getUnique($apiRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably add a _spec function for this API action too. Check:
https://docs.civicrm.org/dev/en/latest/framework/api-architecture/#spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std is lcase - ie getunique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Actually our coding standards don't have anything that suggests putting two words together without either camelCase or an underscore. We should be following the agreed standards as much as possible, @eileenmcnaughton https://docs.civicrm.org/dev/en/latest/standards/php/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - this is the api functions std not something general
If this is a greenfield project, consider using Api V4. https://github.com/civicrm/api4 |
@colemanw this is proposed to build on extensions that work on api v3 already & TBH we already rejected a change for core & this is the less intrusive core change proposed coming off that. I'm OK with this in principle. Note if we DID add the unique custom field type this should also be extended to return those fields @vinuvarshith you don't need to query the DB - the DAOs have an indices function you can use. Note this will need a unit test - also the PR description should include a code snippet calling this api & what the response looks like. |
@eileenmcnaughton |
@vinuvarshith if this is ready for review can you remove the WIP tag. Also check the comment about casing - I know it's a bit ugly to do getunique - but consistent with getfields getsingle etc |
@eileenmcnaughton |
I'd like to request the following change to satisfy r-doc:
|
@seanmadsen |
Small correction -- it looks like the tests weren't properly run on this PR. (Jenkins wanted confirmation from an admin before it would run the tests.) I suspect there's no real harm in this case, though I had a small issue where |
Overview
This is a new api that will go through the indexes of an entity table and return all unique fields (including combination indexes).
This feature was proposed in a disscusion here
eileenmcnaughton/nz.co.fuzion.csvimport#13
Before
It's not currently possible to get a list of unique fields (or combinations) for a given entity.
After
A new api is added to get a list of all unique fields for a given entity.
Technical Details
Sample API call using 'Contribution' entity:
$result = civicrm_api3('Contribution', 'getunique');
Result: