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

noirbizarre / flask-restplus / 793 / 3
38%
master: 38%

Build:
DEFAULT BRANCH: master
Ran 12 Sep 2019 03:11PM UTC
Files 20
Run time 1s
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

12 Sep 2019 03:05PM UTC coverage: 96.573% (-0.2%) from 96.802%
793.3

push

travis-ci

SteadBytes
Fix ambiguity error with Polymorphism candidates (isinstance() problem) (#691)

* Fix for better Polymorphism support

Right now Polymorphism fails when using something like this (models in sqlalchemy):

models:

```python
class Product(BaseModel):
	discr = Column(String)

	__mapper_args__ = {
		'polymorphic_on': discr,
        'polymorphic_identity': "product"
	}

class VegetableProduct(Product):
	name = Column(String)

    __mapper_args__ = {
		'polymorphic_identity': "vegetable"
	}

class DairyProduct(VegetableProduct):
    __mapper_args__ = {
		'polymorphic_identity': "dairy"
	}
```

mapper:

```python
resource_product = api.model("Product", {
	'discr': fields.String
})

product_mapper = {
	VegetableProduct: api.inherit("Vegetable", resource_product, { 'name': fields.String }),
	DairyProduct: api.inherit("Dairy", resource_product, { 'name': fields.String }),
}

resource_result = api.model("ResourceResult", {
	'products': fields.List(fields.Polymorphism(product_mapper))
})
```

This sparkles error here:

https://github.com/noirbizarre/flask-restplus/blob/master/flask_restplus/fields.py#L682

Because candidates will be: VegetableProduct and DairyProduct, since isinstance() will return True for both classes (I personally surprised it works like this)

Checking by __class__.__name__ removes this error and it works as intended.

I hope my quick fix did not break anything, I'm eager to update it if I don't know, more elegant solution is needed.

* adjusted ambiguity test for new feature

* stricter check for type

* changed to simple class check

* type() check for Polymorphism, adjusted tests

* type() check for Polymorphism, adjusted tests

* removed local dev files

* updated test name, also PR in docblock

2536 of 2626 relevant lines covered (96.57%)

0.97 hits per line

Source Files on job 793.3
  • Tree
  • List 0
  • Changed 5
  • Source Changed 1
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 735
  • Travis Job 793.3
  • a7e363a8 on github
  • Prev Job for on master (#789.1)
  • Next Job for on master (#807.1)
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