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

The order of primary keys are wrong in the belongs_to relation #586

Closed
Xoshbin opened this issue Feb 4, 2022 · 0 comments · Fixed by #590
Closed

The order of primary keys are wrong in the belongs_to relation #586

Xoshbin opened this issue Feb 4, 2022 · 0 comments · Fixed by #590
Labels
bug An existing feature is not working as intended

Comments

@Xoshbin
Copy link

Xoshbin commented Feb 4, 2022

Describe the bug
It will be assumed here that the primary key of the relationship here between users and companies is id -> {method_name}_id. You can change the relating columns if that is not the case:

This part in the "ORM documentation is not implemented properly in the "package",

class Post(Model):
@belongs_to('source_id', 'id')
    def source(self):
        from app.models.Source import Source
        return Source

this code is working properly. But when i remove the parameters as said in the documetation it's exchanging the order of the paramters and giving the error below:

class Post(Model):
@belongs_to
    def source(self):
        from app.models.Source import Source
        return Source

no such column: sources.source_id

Basically when I add the relationship with parameters. its working well:
@belongs_to('source_id', 'id')
but when I remove the parameters as in the documentation:
@belongs_to
it gives this error:
no such column: sources.source_id

so as in the error it's supposed to be: "posts.source_id" not "sources.source_id"

Desktop (please complete the following information):

  • OS: [Mac OSX]
  • Version [Monterery 12.2]

What database are you using?

  • Type: [SQLite]
  • Masonite ORM [2.0]
@Xoshbin Xoshbin added the bug An existing feature is not working as intended label Feb 4, 2022
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