If you try this call:

/api/test/node?parameters[type]=wiki&fields=nid,type

The query will fail.

In node_resource.inc line 291:

  // Build an array of fields with the appropriate placeholders for use in
  // db_query().
  foreach ($parameters as $field => $value) {
    $where[] = $field . ' = ' . db_type_placeholder($schema['fields'][$field]['type']);
  }

  // Now implode that array into an actual WHERE clause.
  $where = !empty($where) ? ' WHERE '. db_escape_string(implode(' AND ', $where)) : '';

db_type_placeholder wraps the placeholder in quotes then db_escape_string escapes the quotes which is unnecessary and breaks the query. The db_escape_string is not needed because db_query will take care of that during binding.

CommentFileSizeAuthor
#2 services-1042416.patch431 byteskylebrowning

Comments

perceptum’s picture

I have confirmed this - and have altered my code as suggested above, which works well

kylebrowning’s picture

Status: Active » Needs review
StatusFileSize
new431 bytes

Thanks ! heres a patch, do test!

gdd’s picture

Status: Needs review » Closed (fixed)

Committed, thanks!