Skip to content

Conversation

RmStorm
Copy link
Contributor

@RmStorm RmStorm commented Nov 12, 2019

When specifying a function to dynamically define a tablename as a declared
attribute it became impossible to overwrite it using a manually defined name.

Look at the test to see the issue, with the original code this test would fail.

When specifying a function to dynamically define a tablename as a declared
attribute it became impossible to overwrite it using a manually defined name.

Look at the test to see the issue, with the original code this test would fail.
@coveralls
Copy link

coveralls commented Nov 12, 2019

Pull Request Test Coverage Report for Build 1966

  • 27 of 27 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 98.492%

Totals Coverage Status
Change from base Build 1959: 0.007%
Covered Lines: 4376
Relevant Lines: 4443

💛 - Coveralls

Comment on lines 169 to 171
if getattr(sub_cls, '__tablename__', None) and \
not callable(getattr(sub_cls, '__tablename__')):
table_name = getattr(sub_cls, '__tablename__')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
But this still doesn't cover all cases, though most likely corner cases. We should move it into the loop.
Could you help to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I can. But which case isn't caught using this? I agree it's nicer to have it in the loop anyways, but I think it's probably good to write another test for any uncaught situation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, one of the parent classes or mixins specify __tablename__ as a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, that makes sense. I added a test for that case as well. Maybe I should also have added some tests that are supposed to throw errors on faulty behaviour... but I think it's good to go like this. Can this be merged and pushed to pypi? And maybe #590 can be merged as well?

This test ensures that the __tablename__ is set correctly according to the
inheritance order of the mixins.
@RmStorm RmStorm requested a review from wwwjfy November 15, 2019 13:00
@wwwjfy
Copy link
Member

wwwjfy commented Nov 18, 2019

Thanks

@wwwjfy wwwjfy merged commit fb07668 into python-gino:master Nov 18, 2019
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.

3 participants