Normalize a SQLAlchemy `Column` type argument (`Integer`, `String(50)`, `db.Boolean`).
(expression: &Expression)
| 640 | |
| 641 | /// Normalize a SQLAlchemy `Column` type argument (`Integer`, `String(50)`, `db.Boolean`). |
| 642 | fn sqlalchemy_type(expression: &Expression) -> Option<String> { |
| 643 | let name = match expression { |
| 644 | Expression::Name(NameExpression { id, .. }) => id.to_string(), |
| 645 | Expression::Attribute(AttributeExpression { attr, .. }) => attr.as_str().to_string(), |
| 646 | Expression::Call(CallExpression { func, .. }) => call_leaf(func)?, |
| 647 | _ => return None, |
| 648 | }; |
| 649 | |
| 650 | let normalized = match name.as_str() { |
| 651 | "Integer" | "BigInteger" | "SmallInteger" => "int", |
| 652 | "String" | "Text" | "Unicode" | "VARCHAR" | "CHAR" => "str", |
| 653 | "Boolean" => "bool", |
| 654 | "Float" | "Numeric" => "float", |
| 655 | "DateTime" => "datetime", |
| 656 | "Date" => "date", |
| 657 | "Time" => "time", |
| 658 | "JSON" => "json", |
| 659 | _ => return Some(name), |
| 660 | }; |
| 661 | |
| 662 | Some(normalized.to_string()) |
| 663 | } |
| 664 | |
| 665 | /// Render an annotation to (type, nullable). `Optional[T]` / `Mapped[T]` unwrap. |
| 666 | fn annotation_type(expression: &Expression) -> (String, bool) { |
nothing calls this directly
no test coverage detected