Не могу подружить модели SAWarning: Non-simple column elements in primary join condition for property

Работаю с Flask и Flask_Sqlalchemy, пытался исправить модели но сделал что-то не так и теперь у меня возникает ошибка

Вот логи:

C:\Users\Shiba Developer\Desktop\2\squad\venv\Lib\site-packages\flask_sqlalchemy\model.py:22: SAWarning: relationship 'Vote.voted_comment' will copy column comments.id to column votes.type_id, which conflicts with relationship(s): 'News.votes' (copies news.id to votes.type_id), 'Vote.voted_news' (copies news.id to votes.type_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="voted_news,votes"' to the 'Vote.voted_comment' relationship. (Background on this warning at: https://sqlalche.me/e/20/qzyx) (This warning originated from the `configure_mappers()` process, which was invoked automatically in response to a user-initiated operation.)
  return cls.query_class(
C:\Users\Shiba Developer\Desktop\2\squad\venv\Lib\site-packages\flask_sqlalchemy\model.py:22: SAWarning: relationship 'Comment.votes' will copy column comments.id to column votes.type_id, which conflicts with relationship(s): 'News.votes' (copies news.id to votes.type_id), 'Vote.voted_news' (copies news.id to votes.type_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="voted_news,votes"' to the 'Comment.votes' relationship. (Background on this warning at: https://sqlalche.me/e/20/qzyx) (This warning originated from the `configure_mappers()` process, which was invoked automatically in response to a user-initiated operation.)
  return cls.query_class(

Много чего пытался сделать, ничего не помогало вот сами модели:

from app import db
from datetime import datetime
from enum import Enum
from sqlalchemy import Column, Integer
import os
from werkzeug.utils import secure_filename


# Enum классы
class VoteType(str, Enum):
    NEWS = "новость"
    COMMENT = "комментарий"

class ChangeType(str, Enum):
    ADDED = "Добавлено"
    UPDATED = "Обновлено"
    DELETED = "Удалено"



# Модель Tag
class Tag(db.Model):
    __tablename__ = "tag"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False, unique=True, index=True, comment="Имя тега")
    
    def __repr__(self):
        return f'<Tag {self.id}: {self.name}>'

# Модель News
class News(db.Model):
    __tablename__ = "news"

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False, comment="Заголовок новости")
    slug = db.Column(db.String(200), nullable=False, unique=True)
    content = db.Column(db.Text, nullable=False, comment="Содержание новости")
    publication_date = db.Column(db.DateTime, default=datetime.utcnow, comment="Дата публикации")
    updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, comment="Дата обновления")
    upvotes_count = db.Column(db.Integer, default=0)
    downvotes_count = db.Column(db.Integer, default=0)
    comments = db.relationship('Comment', backref='news', lazy='dynamic', cascade="all, delete")
    dominant_color = db.Column(db.String(7), default='#FFFFFF', comment="Доминирующий цвет изображения")
    author_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False, comment="ID автора", index=True)

    images = db.relationship('NewsImage', backref='news', lazy='dynamic')
    
    votes = db.relationship('Vote', backref='voted_news', lazy='dynamic', cascade="all, delete-orphan",
                            primaryjoin="and_(Vote.type_id==News.id, Vote.type=='новость')")

    def to_dict(self):
        columns = [c.key for c in class_mapper(self.__class__).columns]
        return {column: getattr(self, column) for column in columns}

    def __repr__(self):
        return f'<News {self.id}: {self.title}>'


# Модель NewsImage
class NewsImage(db.Model):
    __tablename__ = "news_images"

    id = db.Column(db.Integer, primary_key=True)
    news_id = db.Column(db.Integer, db.ForeignKey('news.id'), nullable=False, comment="ID новости")
    image_path = db.Column(db.String(255), nullable=False, comment="Путь к изображению на сервере")
    upload_date = db.Column(db.DateTime, default=datetime.utcnow, comment="Дата загрузки изображения")
    file_size = db.Column(db.Integer, nullable=True, comment="Размер файла в байтах")

    def __repr__(self):
        return f'<NewsImage {self.id} for News {self.news_id}>'

    def update_file_size(self, app):
        file_path = os.path.join(app.config['NEWS_IMAGES_BASE'], secure_filename(self.image_path))
        if os.path.exists(file_path):
            self.file_size = os.path.getsize(file_path)
            db.session.commit()

class Comment(db.Model):
    __tablename__ = "comments"

    id = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.Text, nullable=False, comment="Текст комментария")
    publication_date = db.Column(db.DateTime, default=datetime.utcnow, comment="Дата публикации комментария")
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False, comment="ID пользователя", index=True)
    news_id = db.Column(db.Integer, db.ForeignKey('news.id'), nullable=True, comment="ID новости", index=True)
    game_post_id = db.Column(db.Integer, db.ForeignKey('game_posts.id'), nullable=True, comment="ID поста игры", index=True)
    parent_id = db.Column(db.Integer, db.ForeignKey('comments.id'), nullable=True)
    replies = db.relationship('Comment', backref=db.backref('parent', remote_side=[id]), lazy='dynamic')

    
    user = db.relationship('User', backref='comments')  
    votes = db.relationship('Vote', backref='voted_comment', lazy='dynamic', cascade="all, delete-orphan",
                            primaryjoin="and_(Vote.type_id==Comment.id, Vote.type=='комментарий')")

    def __repr__(self):
        return f'<Comment {self.id} by User {self.user_id}>'


# Модель Vote
class Vote(db.Model):
    __tablename__ = "votes"

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False, index=True)
    upvote = db.Column(db.Boolean, nullable=False, comment="True - голос вверх, False - голос вниз")
    type = db.Column(db.Enum(VoteType), nullable=False, comment="Тип объекта: новость или комментарий")
    type_id = db.Column(db.Integer, nullable=False, comment="ID объекта типа (новости или комментария)")

    __table_args__ = (db.UniqueConstraint('user_id', 'type', 'type_id', name='_user_vote_uc'),
                      db.ForeignKeyConstraint(['type_id'], ['news.id'], name='fk_vote_news',
                                              use_alter=True, info={'type': 'новость'}),
                      db.ForeignKeyConstraint(['type_id'], ['comments.id'], name='fk_vote_comment',
                                              use_alter=True, info={'type': 'комментарий'}))

# Модель NewsChangeLog
class NewsChangeLog(db.Model):
    __tablename__ = "news_change_log"

    id = db.Column(db.Integer, primary_key=True)
    news_id = db.Column(db.Integer, db.ForeignKey('news.id'), nullable=False, index=True, comment="ID новости")
    changed_at = db.Column(db.DateTime, default=datetime.utcnow, comment="Дата изменения")
    change_type = db.Column(db.Enum(ChangeType), nullable=False, comment="Тип изменения", index=True)
    
    def __repr__(self):
        return f'<NewsChangeLog {self.id} for News {self.news_id} at {self.changed_at}>'

# Вспомогательная таблица news_tags
news_tags = db.Table('news_tags',
    db.Column('tag_id', db.Integer, db.ForeignKey('tag.id'), primary_key=True),
    db.Column('news_id', db.Integer, db.ForeignKey('news.id'), primary_key=True)
)

# Добавление отношений
News.images = db.relationship('NewsImage', backref='news_item', lazy=True, cascade="all, delete-orphan")
News.tags = db.relationship('Tag', secondary=news_tags, lazy='joined', backref=db.backref('news_items', lazy=True))

Ответы (0 шт):