phramework / jsonapi

jsonapi implementation for phramework
https://phramework.github.io/jsonapi/
Apache License 2.0
4 stars 2 forks source link

Cannot patch boolean to false when using postgresql #56

Open nohponex opened 7 years ago

nohponex commented 7 years ago
{
      "data": {
        "id": "42",
        "type": "article",
        "attributes": {
          "useful": false
        }
      }
    }

Using bypass

     /**
     * Override patch, to "hack" boolean behaviour
     * @param mixed  $id
     * @param object $attributes
     * @return int
     */
    public static function patch($id, $attributes)
    {
        if (isset($attributes['useful']) && $attributes['useful'] === false) {
            $attributes['useful'] = 0;
        }

        return parent::patch($id, $attributes);
    }