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

Fix recordid not passing in FMBaseBuilder::get() with empty whereIns #90

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/Services/FileMakerConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,25 @@ public function getRecords(FMBaseBuilder $query)
// default to an empty array
$queryParams = [];

// handle single record requests
if ($query->getRecordId() !== null) {
$url .= (Str::endsWith($url, '/') ? '' : '/') . $query->getRecordId();
} else {
// handle pagination and sorting
// these parameters are not used for single record requests
if ($query->offset > 0) {
// Offset is 1-indexed
$queryParams['_offset'] = $query->offset + 1;
}
if ($query->limit > 0) {
$queryParams['_limit'] = $query->limit;
}
if ($query->orders !== null && count($query->orders) > 0) {
// sort can have many values, so it needs to get json_encoded and passed as a single string
$queryParams['_sort'] = json_encode($query->orders);
}
}

// handle scripts
if ($query->script !== null) {
$queryParams['script'] = $query->script;
Expand All @@ -315,23 +334,13 @@ public function getRecords(FMBaseBuilder $query)
if ($query->scriptPrerequestParam !== null) {
$queryParams['script.prerequest.param'] = $query->scriptPrerequestParam;
}

if ($query->layoutResponse !== null) {
$queryParams['layout.response'] = $query->layoutResponse;
}
if ($query->portal !== null) {
$queryParams['portal'] = $query->portal;
}
if ($query->offset > 0) {
// Offset is 1-indexed
$queryParams['_offset'] = $query->offset + 1;
}
if ($query->limit > 0) {
$queryParams['_limit'] = $query->limit;
}
if ($query->orders !== null && count($query->orders) > 0) {
// sort can have many values, so it needs to get json_encoded and passed as a single string
$queryParams['_sort'] = json_encode($query->orders);
}

$response = $this->makeRequest('get', $url, $queryParams);

Expand Down
Loading