Skip to content

Commit 97d0560

Browse files
committed
Corrected a typo in the schema definition and simplified the read_one() people.py method.
1 parent 00306ee commit 97d0560

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

flask-connexion-rest-part-3/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class PersonSchema(ma.ModelSchema):
3636
class Meta:
3737
model = Person
3838
sqla_session = db.session
39-
notes = fields.Nested('PersonNotesSchema', default=[], many=True)
39+
notes = fields.Nested('PersonNoteSchema', default=[], many=True)
4040

4141

42-
class PersonNotesSchema(ma.ModelSchema):
42+
class PersonNoteSchema(ma.ModelSchema):
4343
"""
4444
This class exists to get around a recursion issue
4545
"""
@@ -53,10 +53,10 @@ class NoteSchema(ma.ModelSchema):
5353
class Meta:
5454
model = Note
5555
sqla_session = db.session
56-
person = fields.Nested('NotesPersonSchema', default=None)
56+
person = fields.Nested('NotePersonSchema', default=None)
5757

5858

59-
class NotesPersonSchema(ma.ModelSchema):
59+
class NotePersonSchema(ma.ModelSchema):
6060
"""
6161
This class exists to get around a recursion issue
6262
"""

flask-connexion-rest-part-3/people.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ def read_one(person_id):
3636
person = Person.query \
3737
.filter(Person.person_id == person_id) \
3838
.outerjoin(Note) \
39-
.options(db.joinedload(Person.notes)) \
4039
.one_or_none()
4140

42-
# Did we find a person?
41+
# Did we find a person?
4342
if person is not None:
4443

4544
# Serialize the data for the response

0 commit comments

Comments
 (0)