Map a base class to its ORM when the field constructors didn't already reveal it.
(bases: &[String])
| 602 | |
| 603 | /// Map a base class to its ORM when the field constructors didn't already reveal it. |
| 604 | fn orm_from_bases(bases: &[String]) -> &'static str { |
| 605 | for base in bases { |
| 606 | let leaf = base.rsplit('.').next().unwrap_or(base); |
| 607 | |
| 608 | match leaf { |
| 609 | "Model" if base.starts_with("models.") => return "django", |
| 610 | "SQLModel" => return "sqlmodel", |
| 611 | "BaseModel" => return "pydantic", |
| 612 | "DeclarativeBase" | "Base" => return "sqlalchemy", |
| 613 | "Model" => return "sqlalchemy", // db.Model (Flask-SQLAlchemy) |
| 614 | _ => {} |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | "unknown" |
| 619 | } |
| 620 | |
| 621 | /// Normalize a Django field constructor to a simple type name. |
| 622 | fn django_type(field: &str) -> String { |