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

Belongs to many - Table can't be without an underscore #803

Closed
maicol07 opened this issue Oct 11, 2022 · 0 comments · Fixed by #825
Closed

Belongs to many - Table can't be without an underscore #803

maicol07 opened this issue Oct 11, 2022 · 0 comments · Fixed by #825
Labels
bug An existing feature is not working as intended

Comments

@maicol07
Copy link
Contributor

maicol07 commented Oct 11, 2022

Describe the bug
In a belongs to many relationship, the table option can't be without an underscore (i.e. compositions), but it should be table1_table2. If this structure isn't present it throws an error when splitting the table name. This behaviour isn't necessary when local_foreign_key and other_foreign_key are set.

To Reproduce
Steps to reproduce the behavior:

  1. Create a sample database with two tables and one "belongstomany" table
  2. Create the models for the table
  3. Use the code below for the "belongs to many" relationship
  4. Try to get the related model & see error

Expected behavior
Table works with the two additional options

Screenshots or code snippets

@belongs_to_many(local_foreign_key="donut_id", other_foreign_key="", pivot_id=None, table="compositions", with_fields=["absolute_quantity"])
    def ingredients(self):
        """Get the ingredients for this donut"""
        from app.Models.Ingredient import Ingredient
        return Ingredient

Desktop (please complete the following information):

  • OS: Windows
  • Version 11

What database are you using?

  • Type: MariaDB
  • Version 10.6.9
  • Masonite ORM 2.18.6
@maicol07 maicol07 added the bug An existing feature is not working as intended label Oct 11, 2022
@maicol07 maicol07 changed the title Belongs to many - Table can't be withotu an underscore Belongs to many - Table can't be without an underscore Oct 12, 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