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

on method should affect only the Model instance #726

Closed
federicoparroni opened this issue Jun 15, 2022 · 0 comments · Fixed by #730
Closed

on method should affect only the Model instance #726

federicoparroni opened this issue Jun 15, 2022 · 0 comments · Fixed by #730
Labels
bug An existing feature is not working as intended

Comments

@federicoparroni
Copy link
Contributor

Describe the bug
In the Model class we have the on method defined both in the __passthrough__ list and a class method:


@classmethod
def on(cls, connection):
cls.__connection__ = connection
return cls

Given this fact, it seems that the classmethod is always called, see the following example:

connection_name = "example-conn"
model = MyModel().on(connection_name)
print(model.builder.connection)    # example-conn
print(MyModel.__connection__)      # example-conn

Expected behavior
The class attribute __connection__ should not be changed.
I think the correct behaviour should be to passthrough the on method towards the QueryBuilder instance, so removing the class method or using another name for it (e.g.: global_on).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing feature is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant