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

adding overlaps to suppress sqlalchemy warnings #72

Merged
merged 1 commit into from
Oct 21, 2022
Merged

Conversation

crooksey
Copy link
Contributor

@crooksey crooksey commented Jul 6, 2022

I recently upgrade sqlalchemy and started getting a few warning messages around the way the models are configured.

This was fixed by adding the "overlaps" as suggested in the below logs:

/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'Group.users_dynamic' will copy column groups.id to column users_groups.group_id, which conflicts with relationship(s): 'Group.users' (copies groups.id to users_groups.group_id), 'User.groups' (copies groups.id to users_groups.group_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="groups,users"' to the 'Group.users_dynamic' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'Group.users_dynamic' will copy column users.id to column users_groups.user_id, which conflicts with relationship(s): 'Group.users' (copies users.id to users_groups.user_id), 'User.groups' (copies users.id to users_groups.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="groups,users"' to the 'Group.users_dynamic' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'Group.resources_dynamic' will copy column groups.id to column resources.owner_group_id, which conflicts with relationship(s): 'Group.resources' (copies groups.id to resources.owner_group_id), 'Resource.owner_group' (copies groups.id to resources.owner_group_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="owner_group,resources"' to the 'Group.resources_dynamic' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'Resource.groups' will copy column resources.resource_id to column groups_resources_permissions.resource_id, which conflicts with relationship(s): 'Resource.group_permissions' (copies resources.resource_id to groups_resources_permissions.resource_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="group_permissions"' to the 'Resource.groups' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'Resource.groups' will copy column groups.id to column groups_resources_permissions.group_id, which conflicts with relationship(s): 'Group.resource_permissions' (copies groups.id to groups_resources_permissions.group_id), 'GroupResourcePermission.groups' (copies groups.id to groups_resources_permissions.group_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="groups,resource_permissions"' to the 'Resource.groups' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'Resource.users' will copy column resources.resource_id to column users_resources_permissions.resource_id, which conflicts with relationship(s): 'Resource.user_permissions' (copies resources.resource_id to users_resources_permissions.resource_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="user_permissions"' to the 'Resource.users' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'User.groups_dynamic' will copy column users.id to column users_groups.user_id, which conflicts with relationship(s): 'Group.users' (copies users.id to users_groups.user_id), 'Group.users_dynamic' (copies users.id to users_groups.user_id), 'User.groups' (copies users.id to users_groups.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="groups,users,users_dynamic"' to the 'User.groups_dynamic' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'User.groups_dynamic' will copy column groups.id to column users_groups.group_id, which conflicts with relationship(s): 'Group.users' (copies groups.id to users_groups.group_id), 'Group.users_dynamic' (copies groups.id to users_groups.group_id), 'User.groups' (copies groups.id to users_groups.group_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="groups,users,users_dynamic"' to the 'User.groups_dynamic' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)
configure_mappers()
/home/luke/nodejs/ngx-intranet/intranet_backend_api/intranet_backend_api/intranet_models/__init__.py:12: SAWarning: relationship 'User.resource_permissions' will copy column users.id to column users_resources_permissions.user_id, which conflicts with relationship(s): 'Resource.users' (copies users.id to users_resources_permissions.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="users"' to the 'User.resource_permissions' relationship. (Background on this error at: https://sqlalche.me/e/14/qzyx)

@crooksey
Copy link
Contributor Author

@ergo any thoughts?

@ergo
Copy link
Owner

ergo commented Oct 21, 2022

Sure

@ergo ergo merged commit b010f8b into ergo:master Oct 21, 2022
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