Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix BindMetaMixin with polymorphic #651

Merged
merged 2 commits into from Oct 30, 2018

Conversation

@minisotm
Copy link
Contributor

commented Oct 29, 2018

AttributeError: 'NoneType' object has no attribute 'info'
flask_sqlalchemy/model.py:124: AttributeError

How to reproduce:

bind_key = 'polymorphic_bind_key'

 app.config['SQLALCHEMY_BINDS'] = {
     bind_key: 'sqlite:///:memory',
 }

 class Base(db.Model):
     __bind_key__ = bind_key

     __tablename__ = 'base'

     id = db.Column(db.Integer, primary_key=True)

     p_type = db.Column(db.String(50))

     __mapper_args__ = {
         'polymorphic_identity': 'base',
         'polymorphic_on': p_type
     }

 class Child1(Base):

     child_1_data = db.Column(db.String(50))
     __mapper_args__ = {
         'polymorphic_identity': 'child_1',
     }
@davidism

This comment has been minimized.

Copy link
Member

commented Oct 29, 2018

Thanks, this looks good. It's been a while since I looked at this, was this failing because hasattr was returning True but it was because __table__ = None?

@minisotm

This comment has been minimized.

Copy link
Contributor Author

commented Oct 29, 2018

Yes, at this moment __table__ is None, but attribute exists.

@davidism

This comment has been minimized.

Copy link
Member

commented Oct 29, 2018

Would you add an entry in the changelog? Then I can merge.

@minisotm

This comment has been minimized.

Copy link
Contributor Author

commented Oct 29, 2018

done

@minisotm

This comment has been minimized.

Copy link
Contributor Author

commented Oct 29, 2018

Oops, version 2.3.2 or 2.3.3?

@davidism

This comment has been minimized.

Copy link
Member

commented Oct 29, 2018

Hmm, didn't realize there wasn't a changelog already. Just create a new section with the next version number and no release date.

@minisotm minisotm force-pushed the minisotm:master branch from 284112e to 5a3422e Oct 29, 2018
@davidism davidism merged commit 500e732 into pallets:master Oct 30, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dirkesquire

This comment has been minimized.

Copy link

commented Dec 11, 2018

I ran into exactly the same problem, so I need this fix.
I see you merged in a fix in October, but when will you be releasing it onto pypi.org?
Currently pypi.org is still showing 2.3.2.

davidism added a commit that referenced this pull request Sep 24, 2019
backport #651 fix BindMetaMixin with polymorphic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.