Skip to content

Commit

Permalink
Update to current 4.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ColtonProvias committed Jun 26, 2016
1 parent 9b8a8db commit 010aa29
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
10 changes: 9 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# SQLAlchemy-JSONAPI Changelog

## 4.0.5
## 4.0.8

*2016-04-32*

* Fixed bug with relationship not being found during resource patch.

## 4.0.5 - 4.0.7

*2016-03-20*

* Fixed missing jsonapi_permissions attribute when patching relationships.
* Fixed AttributeError on GET related of a NoneType.
* Fixed where meta was now always being injected into non-204 responses.

## 4.0.4

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
requirements.append('enum34')

setup(name='SQLAlchemy-JSONAPI',
version='4.0.5',
version='4.0.8',
url='http://github.com/coltonprovias/sqlalchemy-jsonapi',
license='MIT',
author='Colton J. Provias',
Expand Down
15 changes: 9 additions & 6 deletions sqlalchemy_jsonapi/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self):
self.status_code = 200
self.data = {
'jsonapi': {'version': '1.0'},
'meta': {'sqlalchemy_jsonapi_version': '4.0.5'}
'meta': {'sqlalchemy_jsonapi_version': '4.0.8'}
}


Expand Down Expand Up @@ -548,7 +548,7 @@ def delete_relationship(self, session, data, api_type, obj_id, rel_key):
return ToManyExpectedError(model, resource, relationship)

response = JSONAPIResponse()
response.data = {'data': []}
response.data = []

session.add(resource)

Expand Down Expand Up @@ -648,7 +648,7 @@ def get_collection(self, session, query, api_key):
start, end = self._parse_page(query)

response = JSONAPIResponse()
response.data = {'data': []}
response.data['data'] = []

for instance in collection:
try:
Expand Down Expand Up @@ -714,8 +714,11 @@ def get_related(self, session, query, api_type, obj_id, rel_key):

if relationship.direction == MANYTOONE:
try:
response.data['data'] = self._render_full_resource(related,
{}, {})
if related is None:
response.data['data'] = None
else:
response.data['data'] = self._render_full_resource(related,
{}, {})
except PermissionDeniedError:
response.data['data'] = None
else:
Expand Down Expand Up @@ -881,7 +884,7 @@ def patch_resource(self, session, json_data, api_type, obj_id):
json_data['data'].setdefault('relationships', {})
json_data['data'].setdefault('attributes', {})

data_keys = set(json_data['data']['relationships'].keys())
data_keys = set(map((lambda x: resource.__jsonapi_map_to_py__.get(x, None)), json_data['data'].get('relationships', {}).keys()))
model_keys = set(resource.__mapper__.relationships.keys())
if not data_keys <= model_keys:
raise BadRequestError(
Expand Down

0 comments on commit 010aa29

Please sign in to comment.