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

Full reproduction of M:N pivot table issue #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinm-facsware
Copy link

@kevinm-facsware kevinm-facsware commented Jul 1, 2024

image

Summary of Operations

1. Creating an Account and User:

  • A new Account and User are created.
  • The user's email is set to 'test123abc@mailinator.com'.
  • The user is added to the account.
  • The account (with the user) is persisted and flushed to the database.

2. Creating a Project and Assigning a User:

  • A new Project is created with the name 'My First Project'.
  • The previously created user is fetched using their email.
  • The association (AccountUser) between the user and account is fetched.
  • If the AccountUser is found, the project is assigned to this AccountUser.
  • The project is persisted and flushed to the database.

3. Creating Documents and Assigning Them:

  • The ORM's entity manager is cleared to simulate a new request.
  • Two new Document objects are created and associated with the previously created account.
  • The project named 'My First Project' is fetched.
  • The user is refetched using their email.
  • The association (AccountUser) is refetched, and specific relations (assignedProjects, assignedDocuments) are populated.
  • Note: Populating these relations causes a blow-up due to a broken relation issue.
  • Once flushed, there is an attempt to create a new account user with an undefined user.

Entity Relationships

AccountUser

  • ManyToOne: account (Account) - Represents the many-to-one relationship with Account.
  • ManyToOne: user (User) - Represents the many-to-one relationship with User, with cascade updates.
  • OneToMany: assignedDocuments (Document) - Represents the one-to-many relationship with Document, where the Document entity refers to this AccountUser as assignee.
  • ManyToMany: assignedProjects (Project) - Represents the many-to-many relationship with Project.

Account

  • PrimaryKey: id - A unique identifier for the account.
  • ManyToMany: users (User) - Represents the many-to-many relationship with User, using AccountUser as the pivot entity.
  • OneToMany: projects (Project) - Represents the one-to-many relationship with Project.

Document

  • PrimaryKey: id - A unique identifier for the document.
  • ManyToOne: project (Project) - Represents the many-to-one relationship with Project.
  • ManyToOne: account (Account) - Represents the many-to-one relationship with Account.
  • ManyToOne: assignee (AccountUser) - Represents the many-to-one relationship with AccountUser, indicating the document's assignee.

Project

  • PrimaryKey: id - A unique identifier for the project.
  • Property: name - The name of the project.
  • ManyToOne: account (Account) - Represents the many-to-one relationship with Account.
  • OneToMany: documents (Document) - Represents the one-to-many relationship with Document, where the Document entity refers to this Project.
  • ManyToMany: assignedUsers (AccountUser) - Represents the many-to-many relationship with AccountUser, indicating users assigned to the project.

User

  • PrimaryKey: id - A unique identifier for the user.
  • Property: email - The unique email address of the user.
  • ManyToMany: accounts (Account) - Represents the many-to-many relationship with Account, mapped by the users property in Account.

Relationship Summary

  • Account and User have a many-to-many relationship through the AccountUser pivot entity.
  • AccountUser has a one-to-many relationship with Document as the assignee and a many-to-many relationship with Project.
  • Account has a one-to-many relationship with Project.
  • Project has a one-to-many relationship with Document and a many-to-many relationship with AccountUser.
  • Document has many-to-one relationships with Project, Account, and AccountUser as the assignee.

@kevinm-facsware kevinm-facsware changed the title Full postgres reproduction Full reproduction of M:N pivot table issue Jul 1, 2024
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