RESTful-Drupal / restful

RESTful best practices for Drupal
https://drupal.org/project/restful
417 stars 173 forks source link

Null Empty values #492

Open iStryker opened 9 years ago

iStryker commented 9 years ago

Currently empty public field values are not getting outputted to the api. After speaking with @nathanv, he said it is best practice for all of them to return NULL. Should we be using this best practice?

e0ipso commented 9 years ago

I don't hold a big preference in this matter. Maybe @nathanv can share some documentation to point to best practises in this case.

Thanks for pointing this out!

vespoli commented 9 years ago

I think it is probably a best practice because as a consumer of the service, it is preferable to not have to always check for the existence of a field before using/checking it's value.

e0ipso commented 9 years ago

Good!

Care to provide a PR? :-)

krisgraham commented 9 years ago

I just created a PR for this. checkPropertyAccess() returns false for fields with no data (in addition to those which the user doesn't have permission to access), so now it just populates the value with the default NULL for either case.

iStryker commented 9 years ago

Tested this with Entity Reference field and it works!

prudloff-insite commented 1 year ago

In cas anyone stumbles on this, here is the PR mentioned by @krisgraham: https://github.com/RESTful-Drupal/restful/pull/505