code: def test_complex_inheritance(db: SQLAlchemy) -> None:
      """Joined table inheritance, but the new primary key is provided by a
      mixin, not directly on the class.
      """
  
      class Duck(db.Model):
          id = sa.Column(sa.Integer, primary_key=True)
  
      class IdMixin:
          @sa_orm.declared_attr
          def id(cls):  # type: ignore[no-untyped-def]  # noqa: B902
              return sa.Column(
                  sa.Integer, sa.ForeignKey(Duck.id), primary_key=True
              )
  
      class RubberDuck(IdMixin, Duck):  # type: ignore[misc]
          pass
  
      assert RubberDuck.__tablename__ == "rubber_duck"
  
imports: from __future__ import annotations
  import inspect
  import typing
  import pytest
  import sqlalchemy
  import sqlalchemy.exc
  import sqlalchemy.orm
  from flask_sqlalchemy import SQLAlchemy
  from flask_sqlalchemy.model import camel_to_snake_case
label_desc: Use image node_id 8 for calling a global function with example usage: test_complex_inheritance(db) and returns: sa