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

Allow find on 'Code' id #170

Merged
merged 2 commits into from Oct 3, 2017
Merged

Allow find on 'Code' id #170

merged 2 commits into from Oct 3, 2017

Conversation

LeonMelis
Copy link
Contributor

Some objects, such as Divisions use an integer ID, instead of the more common GUID. To do a filter on ID the syntax in the Exact API is slighty different:
Code eq 5
versus
EntryId eq guid'1a2b3c...'

This PR allows doing a find() on both types of ID.

Example:
$division = (new Division($connection))->find($me->CurrentDivision);

@@ -5,8 +5,14 @@

public function find($id)
{
if ($this->primaryKey === 'Code') {
Copy link
Member

Choose a reason for hiding this comment

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

Thank you.

It's a little nicer to change it to not use an else statement. This way it has a clear default.

$filter = $this->primaryKey . " eq guid'$id'";

if ($this->primaryKey === 'Code') {
    $filter = $this->primaryKey . " eq $id";
}

@LeonMelis
Copy link
Contributor Author

No problem, I pushed the improved version. Thanks for the great work on the library!

@stephangroen stephangroen merged commit 1d40b42 into picqer:master Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants