MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / sqlalchemy_type

Function sqlalchemy_type

plugins/ast/python/src/lib.rs:642–663  ·  view source on GitHub ↗

Normalize a SQLAlchemy `Column` type argument (`Integer`, `String(50)`, `db.Boolean`).

(expression: &Expression)

Source from the content-addressed store, hash-verified

640
641/// Normalize a SQLAlchemy `Column` type argument (`Integer`, `String(50)`, `db.Boolean`).
642fn 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.
666fn annotation_type(expression: &Expression) -> (String, bool) {

Callers

nothing calls this directly

Calls 1

call_leafFunction · 0.85

Tested by

no test coverage detected