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

Infer collection_name from __table__ #436

Merged

Conversation

donkopotamus
Copy link
Contributor

Model classes that have been defined in a declarative style are not guaranteed to have a __tablename__ attribute. For example, if they have been declared in a hybrid style with an embedded table:

class example(base):
    __table__ = Table(...)

However even those declared just via a __tablename_ will have a __table__ attribute (created by the metaclass), so to infer the collection name in all cases we should use __table__.name.

Model classes that have been defined in a declarative style are not guaranteed to have a `__tablename__` attribute.  For example, if they have been declared in a hybrid style with an embedded table:

    class example(base):
        __table__ = Table(...)

However even those declared just via a `__tablename_` will have a `__table__` attribute (created by the metaclass), so to infer the collection name in all cases we should use `__table__.name`.
jfinkels added a commit that referenced this pull request Feb 4, 2016
Infer collection_name from __table__ instead of __tablename__
@jfinkels jfinkels merged commit 553c0b6 into jfinkels:master Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants