{"action":"created","comment":{"url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/comments/23362797","id":23362797,"diff_hunk":"@@ -140,7 +140,9 @@ protected function queryForListSort(\\EntityFieldQuery $query) {\n \n     foreach ($sorts as $public_field_name => $direction) {\n       // Determine if sorting is by field or property.\n-      $property_name = $public_fields[$public_field_name]['property'];\n+      if (!$property_name = $public_fields[$public_field_name]['property']) {","path":"plugins/restful/RestfulDataProviderEFQ.php","position":5,"original_position":5,"commit_id":"165c31cde8af338b00f65497490cda5d8e6de497","original_commit_id":"165c31cde8af338b00f65497490cda5d8e6de497","user":{"login":"amitaibu","id":125707,"avatar_url":"https://avatars.githubusercontent.com/u/125707?v=3","gravatar_id":"","url":"https://api.github.com/users/amitaibu","html_url":"https://github.com/amitaibu","followers_url":"https://api.github.com/users/amitaibu/followers","following_url":"https://api.github.com/users/amitaibu/following{/other_user}","gists_url":"https://api.github.com/users/amitaibu/gists{/gist_id}","starred_url":"https://api.github.com/users/amitaibu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitaibu/subscriptions","organizations_url":"https://api.github.com/users/amitaibu/orgs","repos_url":"https://api.github.com/users/amitaibu/repos","events_url":"https://api.github.com/users/amitaibu/events{/privacy}","received_events_url":"https://api.github.com/users/amitaibu/received_events","type":"User","site_admin":false},"body":"I think we should use ``\\RestfulDataProviderEFQ::getColumnFromProperty`` here (and maybe improve it to return FALSE of no ``schema field`` found) - as EMW allows defining \"computed\" properties that have no real schema field.","created_at":"2015-01-22T09:11:51Z","updated_at":"2015-01-22T09:11:51Z","html_url":"https://github.com/RESTful-Drupal/restful/pull/385#discussion_r23362797","pull_request_url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385","_links":{"self":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/comments/23362797"},"html":{"href":"https://github.com/RESTful-Drupal/restful/pull/385#discussion_r23362797"},"pull_request":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385"}}},"pull_request":{"url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385","id":27825734,"html_url":"https://github.com/RESTful-Drupal/restful/pull/385","diff_url":"https://github.com/RESTful-Drupal/restful/pull/385.diff","patch_url":"https://github.com/RESTful-Drupal/restful/pull/385.patch","issue_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/385","number":385,"state":"open","locked":false,"title":"defaultSort fails with custom resource properties returns SQL error","user":{"login":"mateu-aguilo-bosch","id":1140906,"avatar_url":"https://avatars.githubusercontent.com/u/1140906?v=3","gravatar_id":"","url":"https://api.github.com/users/mateu-aguilo-bosch","html_url":"https://github.com/mateu-aguilo-bosch","followers_url":"https://api.github.com/users/mateu-aguilo-bosch/followers","following_url":"https://api.github.com/users/mateu-aguilo-bosch/following{/other_user}","gists_url":"https://api.github.com/users/mateu-aguilo-bosch/gists{/gist_id}","starred_url":"https://api.github.com/users/mateu-aguilo-bosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mateu-aguilo-bosch/subscriptions","organizations_url":"https://api.github.com/users/mateu-aguilo-bosch/orgs","repos_url":"https://api.github.com/users/mateu-aguilo-bosch/repos","events_url":"https://api.github.com/users/mateu-aguilo-bosch/events{/privacy}","received_events_url":"https://api.github.com/users/mateu-aguilo-bosch/received_events","type":"User","site_admin":false},"body":"I have a custom property added to a custom resource that extends `RestfulEntityBaseNode` like so:\r\n\r\n```\r\n<?php\r\n\r\nclass Example extends RestfulEntityBaseNode {\r\n\r\n  public function publicFieldsInfo() {\r\n    $public_fields = parent::publicFieldsInfo();\r\n\r\n    $public_fields['weight'] = array(\r\n      'callback' => array($this, 'customWeightCallback'),\r\n    );\r\n  }\r\n\r\n  public function defaultSortInfo() {\r\n    return array(\r\n      'weight' => 'ASC',\r\n    );\r\n  }\r\n\r\n  protected function customWeightCallback($entity) {\r\n    return 0; // Could return anything\r\n  }\r\n}\r\n\r\n```\r\nAccording to the documentation this should be supported, from plugin.md:\r\n\r\n> ## Defining a default sort\r\n   You can also define default sort fields in your plugin, by overriding `defaultSortInfo()` in your class definition.\r\n>\r\n> This method should return an associative array, with each element having a key that matches a field from `publicFieldsInfo()`, and a value of either 'ASC' or 'DESC'.\r\n\r\nBut what happens is that this throws an error:\r\n\r\n```\r\n{\"type\":\"http:\\/\\/www.w3.org\\/Protocols\\/rfc2616\\/rfc2616-sec10.html#sec10.5.1\",\r\n\"title\":\"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \\u0027ASC\\nLIMIT 50 OFFSET 0\\u0027 at line 2\",\"status\":500}\r\n```\r\n\r\nIt appears that the current sort functionality perhaps only allow things that are actually queried out of the database, not calculated properties\r\n\r\nAre custom properties supported as a sort parameter?","created_at":"2015-01-22T08:37:26Z","updated_at":"2015-01-22T09:11:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dfdd962cf2382d6e9673ad611455fc2b7c041909","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385/commits","review_comments_url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385/comments","review_comment_url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/comments/{number}","comments_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/385/comments","statuses_url":"https://api.github.com/repos/RESTful-Drupal/restful/statuses/165c31cde8af338b00f65497490cda5d8e6de497","head":{"label":"mateu-aguilo-bosch:385-sql-sort-fail","ref":"385-sql-sort-fail","sha":"165c31cde8af338b00f65497490cda5d8e6de497","user":{"login":"mateu-aguilo-bosch","id":1140906,"avatar_url":"https://avatars.githubusercontent.com/u/1140906?v=3","gravatar_id":"","url":"https://api.github.com/users/mateu-aguilo-bosch","html_url":"https://github.com/mateu-aguilo-bosch","followers_url":"https://api.github.com/users/mateu-aguilo-bosch/followers","following_url":"https://api.github.com/users/mateu-aguilo-bosch/following{/other_user}","gists_url":"https://api.github.com/users/mateu-aguilo-bosch/gists{/gist_id}","starred_url":"https://api.github.com/users/mateu-aguilo-bosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mateu-aguilo-bosch/subscriptions","organizations_url":"https://api.github.com/users/mateu-aguilo-bosch/orgs","repos_url":"https://api.github.com/users/mateu-aguilo-bosch/repos","events_url":"https://api.github.com/users/mateu-aguilo-bosch/events{/privacy}","received_events_url":"https://api.github.com/users/mateu-aguilo-bosch/received_events","type":"User","site_admin":false},"repo":{"id":19935082,"name":"restful","full_name":"mateu-aguilo-bosch/restful","owner":{"login":"mateu-aguilo-bosch","id":1140906,"avatar_url":"https://avatars.githubusercontent.com/u/1140906?v=3","gravatar_id":"","url":"https://api.github.com/users/mateu-aguilo-bosch","html_url":"https://github.com/mateu-aguilo-bosch","followers_url":"https://api.github.com/users/mateu-aguilo-bosch/followers","following_url":"https://api.github.com/users/mateu-aguilo-bosch/following{/other_user}","gists_url":"https://api.github.com/users/mateu-aguilo-bosch/gists{/gist_id}","starred_url":"https://api.github.com/users/mateu-aguilo-bosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mateu-aguilo-bosch/subscriptions","organizations_url":"https://api.github.com/users/mateu-aguilo-bosch/orgs","repos_url":"https://api.github.com/users/mateu-aguilo-bosch/repos","events_url":"https://api.github.com/users/mateu-aguilo-bosch/events{/privacy}","received_events_url":"https://api.github.com/users/mateu-aguilo-bosch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mateu-aguilo-bosch/restful","description":"RESTful best practices for Drupal","fork":true,"url":"https://api.github.com/repos/mateu-aguilo-bosch/restful","forks_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/forks","keys_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/teams","hooks_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/hooks","issue_events_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/issues/events{/number}","events_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/events","assignees_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/assignees{/user}","branches_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/branches{/branch}","tags_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/tags","blobs_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/git/refs{/sha}","trees_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/statuses/{sha}","languages_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/languages","stargazers_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/stargazers","contributors_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/contributors","subscribers_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/subscribers","subscription_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/subscription","commits_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/commits{/sha}","git_commits_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/git/commits{/sha}","comments_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/comments{/number}","issue_comment_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/issues/comments/{number}","contents_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/contents/{+path}","compare_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/merges","archive_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/downloads","issues_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/issues{/number}","pulls_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/pulls{/number}","milestones_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/milestones{/number}","notifications_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/labels{/name}","releases_url":"https://api.github.com/repos/mateu-aguilo-bosch/restful/releases{/id}","created_at":"2014-05-19T08:55:09Z","updated_at":"2015-01-20T17:02:57Z","pushed_at":"2015-01-22T08:48:25Z","git_url":"git://github.com/mateu-aguilo-bosch/restful.git","ssh_url":"git@github.com:mateu-aguilo-bosch/restful.git","clone_url":"https://github.com/mateu-aguilo-bosch/restful.git","svn_url":"https://github.com/mateu-aguilo-bosch/restful","homepage":"","size":2641,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"7.x-1.x"}},"base":{"label":"RESTful-Drupal:7.x-1.x","ref":"7.x-1.x","sha":"d1076c64bf682df660b603c67c0389aa67ab8894","user":{"login":"RESTful-Drupal","id":10175793,"avatar_url":"https://avatars.githubusercontent.com/u/10175793?v=3","gravatar_id":"","url":"https://api.github.com/users/RESTful-Drupal","html_url":"https://github.com/RESTful-Drupal","followers_url":"https://api.github.com/users/RESTful-Drupal/followers","following_url":"https://api.github.com/users/RESTful-Drupal/following{/other_user}","gists_url":"https://api.github.com/users/RESTful-Drupal/gists{/gist_id}","starred_url":"https://api.github.com/users/RESTful-Drupal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RESTful-Drupal/subscriptions","organizations_url":"https://api.github.com/users/RESTful-Drupal/orgs","repos_url":"https://api.github.com/users/RESTful-Drupal/repos","events_url":"https://api.github.com/users/RESTful-Drupal/events{/privacy}","received_events_url":"https://api.github.com/users/RESTful-Drupal/received_events","type":"Organization","site_admin":false},"repo":{"id":17918315,"name":"restful","full_name":"RESTful-Drupal/restful","owner":{"login":"RESTful-Drupal","id":10175793,"avatar_url":"https://avatars.githubusercontent.com/u/10175793?v=3","gravatar_id":"","url":"https://api.github.com/users/RESTful-Drupal","html_url":"https://github.com/RESTful-Drupal","followers_url":"https://api.github.com/users/RESTful-Drupal/followers","following_url":"https://api.github.com/users/RESTful-Drupal/following{/other_user}","gists_url":"https://api.github.com/users/RESTful-Drupal/gists{/gist_id}","starred_url":"https://api.github.com/users/RESTful-Drupal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RESTful-Drupal/subscriptions","organizations_url":"https://api.github.com/users/RESTful-Drupal/orgs","repos_url":"https://api.github.com/users/RESTful-Drupal/repos","events_url":"https://api.github.com/users/RESTful-Drupal/events{/privacy}","received_events_url":"https://api.github.com/users/RESTful-Drupal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RESTful-Drupal/restful","description":"RESTful best practices for Drupal","fork":false,"url":"https://api.github.com/repos/RESTful-Drupal/restful","forks_url":"https://api.github.com/repos/RESTful-Drupal/restful/forks","keys_url":"https://api.github.com/repos/RESTful-Drupal/restful/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RESTful-Drupal/restful/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RESTful-Drupal/restful/teams","hooks_url":"https://api.github.com/repos/RESTful-Drupal/restful/hooks","issue_events_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/events{/number}","events_url":"https://api.github.com/repos/RESTful-Drupal/restful/events","assignees_url":"https://api.github.com/repos/RESTful-Drupal/restful/assignees{/user}","branches_url":"https://api.github.com/repos/RESTful-Drupal/restful/branches{/branch}","tags_url":"https://api.github.com/repos/RESTful-Drupal/restful/tags","blobs_url":"https://api.github.com/repos/RESTful-Drupal/restful/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RESTful-Drupal/restful/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RESTful-Drupal/restful/git/refs{/sha}","trees_url":"https://api.github.com/repos/RESTful-Drupal/restful/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RESTful-Drupal/restful/statuses/{sha}","languages_url":"https://api.github.com/repos/RESTful-Drupal/restful/languages","stargazers_url":"https://api.github.com/repos/RESTful-Drupal/restful/stargazers","contributors_url":"https://api.github.com/repos/RESTful-Drupal/restful/contributors","subscribers_url":"https://api.github.com/repos/RESTful-Drupal/restful/subscribers","subscription_url":"https://api.github.com/repos/RESTful-Drupal/restful/subscription","commits_url":"https://api.github.com/repos/RESTful-Drupal/restful/commits{/sha}","git_commits_url":"https://api.github.com/repos/RESTful-Drupal/restful/git/commits{/sha}","comments_url":"https://api.github.com/repos/RESTful-Drupal/restful/comments{/number}","issue_comment_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues/comments/{number}","contents_url":"https://api.github.com/repos/RESTful-Drupal/restful/contents/{+path}","compare_url":"https://api.github.com/repos/RESTful-Drupal/restful/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RESTful-Drupal/restful/merges","archive_url":"https://api.github.com/repos/RESTful-Drupal/restful/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RESTful-Drupal/restful/downloads","issues_url":"https://api.github.com/repos/RESTful-Drupal/restful/issues{/number}","pulls_url":"https://api.github.com/repos/RESTful-Drupal/restful/pulls{/number}","milestones_url":"https://api.github.com/repos/RESTful-Drupal/restful/milestones{/number}","notifications_url":"https://api.github.com/repos/RESTful-Drupal/restful/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RESTful-Drupal/restful/labels{/name}","releases_url":"https://api.github.com/repos/RESTful-Drupal/restful/releases{/id}","created_at":"2014-03-19T19:58:55Z","updated_at":"2015-01-21T20:51:44Z","pushed_at":"2015-01-21T20:51:44Z","git_url":"git://github.com/RESTful-Drupal/restful.git","ssh_url":"git@github.com:RESTful-Drupal/restful.git","clone_url":"https://github.com/RESTful-Drupal/restful.git","svn_url":"https://github.com/RESTful-Drupal/restful","homepage":"","size":6026,"stargazers_count":173,"watchers_count":173,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":35,"forks":38,"open_issues":35,"watchers":173,"default_branch":"7.x-1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385"},"html":{"href":"https://github.com/RESTful-Drupal/restful/pull/385"},"issue":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/issues/385"},"comments":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/issues/385/comments"},"review_comments":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385/comments"},"review_comment":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/pulls/385/commits"},"statuses":{"href":"https://api.github.com/repos/RESTful-Drupal/restful/statuses/165c31cde8af338b00f65497490cda5d8e6de497"}}}}