Fix(crud) include param lookup now works w/plurals #26

Merged
joeybaker merged 3 commits from fix-include into master 2016-10-26 18:42:15 +00:00
joeybaker commented 2016-10-26 18:37:18 +00:00 (Migrated from github.com)

Previously, {one,many}-to-many relationships with models would result in
associationNames that were plural. e.g. Team might have many players
and one location. The validation was expecting to see the plural
Players and the singular Location but Sequelize is expecting the
singular Player (Location worked fine). This meant that include lookups
would silently fail. This fixes the problem in a backward- compatible way.

It continues to allow include=Location (capitalized) for backward-
compatibility. And now allows and actually does the lookup for
include=players, include=player, include=Player, include=Players
lookup relationships.

There are also a few small changes that enable the above.

I'm working on a separate PR that adds integration tests so that we can ensure this kind of thing doesn't happen again.

Previously, {one,many}-to-many relationships with models would result in `associationNames` that were plural. e.g. `Team` might have many players and one location. The validation was expecting to see the plural `Players` and the singular `Location` but Sequelize is expecting the singular `Player` (`Location` worked fine). This meant that include lookups would silently fail. This fixes the problem in a backward- compatible way. It continues to allow `include=Location` (capitalized) for backward- compatibility. And now allows and actually does the lookup for `include=players`, `include=player`, `include=Player`, `include=Players` lookup relationships. There are also a few small changes that enable the above. I'm working on a separate PR that adds integration tests so that we can ensure this kind of thing doesn't happen again.
joeybaker commented 2016-10-26 18:37:48 +00:00 (Migrated from github.com)

cc @mdibaiee

cc @mdibaiee
mdibaiee commented 2016-10-26 18:41:38 +00:00 (Migrated from github.com)

@joeybaker: Thanks Joey! Looks fine to me 👍

@joeybaker: Thanks Joey! Looks fine to me :+1:
joeybaker commented 2016-10-26 18:44:39 +00:00 (Migrated from github.com)

Released as 2.7.1

Released as 2.7.1
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: thereadme/hapi-sequelize-crud#26
No description provided.