Fix on Speaker Filter Query

When fields for filtering were invalid
where clause was empty causing a sql error.

Change-Id: I57f6bc9765bea2d6693415efe6cdb599dd724994
This commit is contained in:
Sebastian Marcet 2017-10-22 00:53:00 -03:00
parent e9f708147c
commit fa75fddbcd
2 changed files with 18 additions and 15 deletions

View File

@ -40,17 +40,20 @@ class DoctrineSpeakerRepository extends SilverStripeDoctrineRepository implement
$extra_filters = '';
$extra_orders = '';
$bindings = array();
$bindings = [];
if(!is_null($filter))
{
$extra_filters = ' WHERE '. $filter->toRawSQL(array
(
'first_name' => 'FirstName',
'last_name' => 'LastName',
'email' => 'Email',
));
$bindings = array_merge($bindings, $filter->getSQLBindings());
$where_conditions = $filter->toRawSQL([
'first_name' => 'FirstName',
'last_name' => 'LastName',
'email' => 'Email',
]);
if(!empty($where_conditions)) {
$extra_filters = " WHERE {$where_conditions}";
$bindings = array_merge($bindings, $filter->getSQLBindings());
}
}
if(!is_null($order))

View File

@ -162,14 +162,14 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
public function testGetCurrentSummitSpeakers()
{
$params = array
(
'id' => 6,
'page' => 1,
$params = [
'id' => 'current',
'page' => 1,
'per_page' => 15,
'filter' => 'first_name=@John,last_name=@Bryce,email=@sebastian@',
'order' => '+first_name,-last_name'
);
'filter' => 'first_name=@John,last_name=@Bryce,email=@sebastian@',
'order' => '+first_name,-last_name'
];
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(