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
Merged

fix BindMetaMixin with polymorphic #651

merged 2 commits into from Oct 30, 2018

Conversation

@minisotm
Copy link
Contributor

@minisotm minisotm 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
Copy link
Member

@davidism davidism 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
Copy link
Contributor Author

@minisotm minisotm commented Oct 29, 2018

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

@davidism
Copy link
Member

@davidism davidism commented Oct 29, 2018

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

@minisotm
Copy link
Contributor Author

@minisotm minisotm commented Oct 29, 2018

done

@minisotm
Copy link
Contributor Author

@minisotm minisotm commented Oct 29, 2018

Oops, version 2.3.2 or 2.3.3?

@davidism
Copy link
Member

@davidism davidism 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.

@davidism davidism merged commit 500e732 into pallets:master Oct 30, 2018
1 check passed
@dirkesquire
Copy link

@dirkesquire dirkesquire 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 issue Sep 24, 2019
backport #651 fix BindMetaMixin with polymorphic
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants