Warnings sur les relations des membres #104

Closed
opened 2 years ago by Darks · 2 comments
Darks commented 2 years ago
Owner

Initialiser les membres via le master script depuis une fresh install déclenche quelques warnings :

/home/lgatin/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:550: SAWarning: relationship 'Member.topics' will copy column user.id to column post.author_id, which conflicts with relationship(s): 'Post.author' (copies user.id to post.author_id), 'User.posts' (copies user.id to post.author_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="author,posts"' to the 'Member.topics' relationship.

mapper = orm.class_mapper(type)

/home/lgatin/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:550: SAWarning: relationship 'Member.programs' will copy column user.id to column post.author_id, which conflicts with relationship(s): 'Post.author' (copies user.id to post.author_id), 'User.posts' (copies user.id to post.author_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="author,posts"' to the 'Member.programs' relationship.

mapper = orm.class_mapper(type)

/home/lgatin/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:550: SAWarning: relationship 'Member.comments' will copy column user.id to column post.author_id, which conflicts with relationship(s): 'Post.author' (copies user.id to post.author_id), 'User.posts' (copies user.id to post.author_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="author,posts"' to the 'Member.comments' relationship.

mapper = orm.class_mapper(type)

Les explications sont assez claires, c'est un problème de duplication de clé distante entre la classe Member, la classe User et les classes sus-citées.

Initialiser les membres via le master script depuis une fresh install déclenche quelques warnings : ``` /home/lgatin/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:550: SAWarning: relationship 'Member.topics' will copy column user.id to column post.author_id, which conflicts with relationship(s): 'Post.author' (copies user.id to post.author_id), 'User.posts' (copies user.id to post.author_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="author,posts"' to the 'Member.topics' relationship. mapper = orm.class_mapper(type) /home/lgatin/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:550: SAWarning: relationship 'Member.programs' will copy column user.id to column post.author_id, which conflicts with relationship(s): 'Post.author' (copies user.id to post.author_id), 'User.posts' (copies user.id to post.author_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="author,posts"' to the 'Member.programs' relationship. mapper = orm.class_mapper(type) /home/lgatin/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:550: SAWarning: relationship 'Member.comments' will copy column user.id to column post.author_id, which conflicts with relationship(s): 'Post.author' (copies user.id to post.author_id), 'User.posts' (copies user.id to post.author_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="author,posts"' to the 'Member.comments' relationship. mapper = orm.class_mapper(type) ``` Les explications sont assez claires, c'est un problème de duplication de clé distante entre la classe `Member`, la classe `User` et les classes sus-citées.
Darks added the bug label 2 years ago
Lephenixnoir self-assigned this 2 years ago
Darks added warning and removed bug labels 2 years ago
Owner

J'ai un peu triché sur la façon de collecter les topics/programmes/commentaires des membres via les posts. Je m'en occupe à la prochaine séance, ça devrait pas être trop dur.

Conclusion : l'ORM c'est quand même pas pratique.

Edit : Et Gitea arrête pas de refuser mes commentaires parce que le CSRF est vieux de plus de 5 minutes. Chiiill.

J'ai un peu triché sur la façon de collecter les topics/programmes/commentaires des membres via les posts. Je m'en occupe à la prochaine séance, ça devrait pas être trop dur. Conclusion : l'ORM c'est quand même pas pratique. Edit : Et Gitea arrête pas de refuser mes commentaires parce que le CSRF est vieux de plus de 5 minutes. Chiiill.
Owner

Done. Rien n'a changé, il faut juste écrire user.comments(), user.topics(), user.programs() avec des parenthèses maintenant puisque c'est des méthodes.

Done. Rien n'a changé, il faut juste écrire `user.comments()`, `user.topics()`, `user.programs()` avec des parenthèses maintenant puisque c'est des méthodes.
Lephenixnoir closed this issue 11 months ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: devs/PCv5#104
Loading…
There is no content yet.