From c3a9137434b2fbcd03d4711dc7211f0889a55c15 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 14 Feb 2025 09:31:37 +0000 Subject: [PATCH] tests: MappedAsDataclass - skip table binding With SQLAlchemy 2.0.36 mapping as a dataclass while also providing a ``__table__`` attribute is not supported. Skip associated test when ``MappedAsDataclass`` is in use. Fixes: #1378 --- tests/test_model_bind.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_model_bind.py b/tests/test_model_bind.py index 7c633c83..e31d33b2 100644 --- a/tests/test_model_bind.py +++ b/tests/test_model_bind.py @@ -1,6 +1,8 @@ from __future__ import annotations +import pytest import sqlalchemy as sa +import sqlalchemy.orm as sa_orm from flask_sqlalchemy import SQLAlchemy @@ -76,6 +78,9 @@ class User(db.Model): def test_explicit_table(db: SQLAlchemy) -> None: + if issubclass(db.Model, (sa_orm.MappedAsDataclass)): + pytest.skip("Explicit table binding with mapped dataclasses not supported") + user_table = db.Table( "user", sa.Column("id", sa.Integer, primary_key=True),