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

Conflicting relationship warning regarding models #124

Closed
AetherUnbound opened this issue May 20, 2022 · 1 comment
Closed

Conflicting relationship warning regarding models #124

AetherUnbound opened this issue May 20, 2022 · 1 comment
Labels
database Related to database models and/or migrations

Comments

@AetherUnbound
Copy link
Collaborator

When running tests, we receive a whole slew of errors related to conflicting relationships. These warnings look like the following:

/usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'User.tags' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'User.tags' relationship.
department = models.Department(

I don't have enough experience with SQL-Alchemy to understand what's going on here, or what might be the problem. This affects the following models:

  • Assignment.baseofficer [officers.id] -> [assignments.officer_id]
  • Face.users [users.id] -> [faces.user_id]
  • Image.users [users.id] -> [raw_images.user_id]
  • Officer.assignments_lazy [officers.id] -> [assignments.officer_id]
  • User.classifications [users.id] -> [raw_images.user_id]
  • User.tags [users.id] -> [faces.user_id]
Full warning output
tests/conftest.py:537
tests/conftest.py:537
tests/conftest.py:537
  /usr/src/app/OpenOversight/tests/conftest.py:537: SAWarning: relationship 'Officer.assignments_lazy' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,officer"' to the 'Officer.assignments_lazy' relationship.
    department = models.Department(

tests/conftest.py:537
tests/conftest.py:537
tests/conftest.py:537
  /usr/src/app/OpenOversight/tests/conftest.py:537: SAWarning: relationship 'Assignment.baseofficer' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id), 'Officer.assignments_lazy' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,assignments_lazy,officer"' to the 'Assignment.baseofficer' relationship.
    department = models.Department(

tests/conftest.py:537
tests/conftest.py:537
tests/conftest.py:537
  /usr/src/app/OpenOversight/tests/conftest.py:537: SAWarning: relationship 'Image.users' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'Image.users' relationship.
    department = models.Department(

tests/conftest.py:537
tests/conftest.py:537
tests/conftest.py:537
  /usr/src/app/OpenOversight/tests/conftest.py:537: SAWarning: relationship 'User.classifications' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'User.classifications' relationship.
    department = models.Department(

tests/conftest.py:537
tests/conftest.py:537
tests/conftest.py:537
  /usr/src/app/OpenOversight/tests/conftest.py:537: SAWarning: relationship 'Face.users' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'Face.users' relationship.
    department = models.Department(

tests/conftest.py:537
tests/conftest.py:537
tests/conftest.py:537
  /usr/src/app/OpenOversight/tests/conftest.py:537: SAWarning: relationship 'User.tags' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'User.tags' relationship.
    department = models.Department(

tests/test_commands.py:86
  /usr/src/app/OpenOversight/tests/test_commands.py:86: SAWarning: relationship 'Officer.assignments_lazy' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,officer"' to the 'Officer.assignments_lazy' relationship.
    department = Department(name=name, short_name=short_name)

tests/test_commands.py:86
  /usr/src/app/OpenOversight/tests/test_commands.py:86: SAWarning: relationship 'Assignment.baseofficer' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id), 'Officer.assignments_lazy' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,assignments_lazy,officer"' to the 'Assignment.baseofficer' relationship.
    department = Department(name=name, short_name=short_name)

tests/test_commands.py:86
  /usr/src/app/OpenOversight/tests/test_commands.py:86: SAWarning: relationship 'Image.users' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'Image.users' relationship.
    department = Department(name=name, short_name=short_name)

tests/test_commands.py:86
  /usr/src/app/OpenOversight/tests/test_commands.py:86: SAWarning: relationship 'User.classifications' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'User.classifications' relationship.
    department = Department(name=name, short_name=short_name)

tests/test_commands.py:86
  /usr/src/app/OpenOversight/tests/test_commands.py:86: SAWarning: relationship 'Face.users' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'Face.users' relationship.
    department = Department(name=name, short_name=short_name)

tests/test_commands.py:86
  /usr/src/app/OpenOversight/tests/test_commands.py:86: SAWarning: relationship 'User.tags' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'User.tags' relationship.
    department = Department(name=name, short_name=short_name)

tests/conftest.py:232
  /usr/src/app/OpenOversight/tests/conftest.py:232: SAWarning: transaction already deassociated from connection
    transaction.rollback()

app/commands.py:598
  /usr/src/app/OpenOversight/app/commands.py:598: SAWarning: relationship 'Officer.assignments_lazy' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,officer"' to the 'Officer.assignments_lazy' relationship.
    dept = Department(

app/commands.py:598
  /usr/src/app/OpenOversight/app/commands.py:598: SAWarning: relationship 'Assignment.baseofficer' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id), 'Officer.assignments_lazy' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,assignments_lazy,officer"' to the 'Assignment.baseofficer' relationship.
    dept = Department(

app/commands.py:598
  /usr/src/app/OpenOversight/app/commands.py:598: SAWarning: relationship 'Image.users' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'Image.users' relationship.
    dept = Department(

app/commands.py:598
  /usr/src/app/OpenOversight/app/commands.py:598: SAWarning: relationship 'User.classifications' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'User.classifications' relationship.
    dept = Department(

app/commands.py:598
  /usr/src/app/OpenOversight/app/commands.py:598: SAWarning: relationship 'Face.users' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'Face.users' relationship.
    dept = Department(

app/commands.py:598
  /usr/src/app/OpenOversight/app/commands.py:598: SAWarning: relationship 'User.tags' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'User.tags' relationship.
    dept = Department(

tests/conftest.py:272
tests/conftest.py:272
tests/conftest.py:272
  /usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'Officer.assignments_lazy' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,officer"' to the 'Officer.assignments_lazy' relationship.
    department = models.Department(

tests/conftest.py:272
tests/conftest.py:272
tests/conftest.py:272
  /usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'Assignment.baseofficer' will copy column officers.id to column assignments.officer_id, which conflicts with relationship(s): 'Assignment.officer' (copies officers.id to assignments.officer_id), 'Officer.assignments' (copies officers.id to assignments.officer_id), 'Officer.assignments_lazy' (copies officers.id to assignments.officer_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="assignments,assignments_lazy,officer"' to the 'Assignment.baseofficer' relationship.
    department = models.Department(

tests/conftest.py:272
tests/conftest.py:272
tests/conftest.py:272
  /usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'Image.users' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'Image.users' relationship.
    department = models.Department(

tests/conftest.py:272
tests/conftest.py:272
tests/conftest.py:272
  /usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'User.classifications' will copy column users.id to column raw_images.user_id, which conflicts with relationship(s): 'Image.user' (copies users.id to raw_images.user_id), 'User.raw_images' (copies users.id to raw_images.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="raw_images,user"' to the 'User.classifications' relationship.
    department = models.Department(

tests/conftest.py:272
tests/conftest.py:272
tests/conftest.py:272
  /usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'Face.users' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'Face.users' relationship.
    department = models.Department(

tests/conftest.py:272
tests/conftest.py:272
tests/conftest.py:272
  /usr/src/app/OpenOversight/tests/conftest.py:272: SAWarning: relationship 'User.tags' will copy column users.id to column faces.user_id, which conflicts with relationship(s): 'Face.user' (copies users.id to faces.user_id), 'User.faces' (copies users.id to faces.user_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards.   To silence this warning, add the parameter 'overlaps="faces,user"' to the 'User.tags' relationship.
    department = models.Department(
@AetherUnbound AetherUnbound added the database Related to database models and/or migrations label May 20, 2022
@sea-kelp
Copy link
Collaborator

sea-kelp commented Jun 2, 2024

This has been fixed

@sea-kelp sea-kelp closed this as completed Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Related to database models and/or migrations
Projects
Status: Done
Development

No branches or pull requests

2 participants