• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

allegro / ralph / 6240
85%

Build:
DEFAULT BRANCH: ng
Ran 15 Jul 2016 01:14PM UTC
Jobs 1
Files 195
Run time 10s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
6240

push

travis-ci

web-flow
Fix generic foreign key prefetch related in polymorphic api (#2584)

Bug: When there is more than one type on `BaseObject` API endpoint (`/api/base-objects/`), custom fields are returned only for objects of the first type

`CustomFieldValue` is model based on `ContentType`s, so it has `GenericForeignKey` to all other models. According to Django documentation for prefetch_related (https://docs.djangoproject.com/en/1.8/ref/models/querysets/#prefetch-related):
"It also supports prefetching of GenericRelation and GenericForeignKey, however, it must be restricted to a homogeneous set of results. For example, prefetching objects referenced by a GenericForeignKey is only supported if the query is restricted to one ContentType."

In case of `BaseObject`, there could be more than one type of object, so prefetch related was working only for the first of them (implicitly adding filter by content type to `CustomFieldValue` prefetch query), resulting in returning empty list of custom fields for objects of different type.

Since `ralph.api.utils.PolymorphicViewSetMixin` is injecting fields to be prefetched for every polymorphic descendant (in this case of BaseObject, ex. DataCenterAsset, BackOfficeAsset etc), the solution was to prefetch custom fields (and potentially any other field) in final viewset for the type (ex. `DataCenterAssetViewSet`), which is later injected to polymorphic (sub)query for objects of this type (instead of calling it once for all).

10201 of 12002 relevant lines covered (84.99%)

0.85 hits per line

Jobs
ID Job ID Ran Files Coverage
2 6240.2 (DJANGO_VERSION=1.8.12 TEST_DB_ENGINE=mysql) 15 Jul 2016 01:14PM UTC 0
84.99
Travis Job 6240.2
Source Files on build 6240
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #6240
  • f703dc0b on github
  • Prev Build on ng (#6224)
  • Next Build on ng (#6242)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc