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

Function django_type

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

Normalize a Django field constructor to a simple type name.

(field: &str)

Source from the content-addressed store, hash-verified

620
621/// Normalize a Django field constructor to a simple type name.
622fn django_type(field: &str) -> String {
623 let normalized = match field {
624 "CharField" | "TextField" | "SlugField" | "EmailField" | "URLField" | "FileField"
625 | "ImageField" | "UUIDField" => "str",
626 "IntegerField" | "BigIntegerField" | "SmallIntegerField" | "PositiveIntegerField"
627 | "AutoField" | "BigAutoField" => "int",
628 "FloatField" => "float",
629 "DecimalField" => "decimal",
630 "BooleanField" | "NullBooleanField" => "bool",
631 "DateTimeField" => "datetime",
632 "DateField" => "date",
633 "TimeField" => "time",
634 "JSONField" => "json",
635 other => other,
636 };
637
638 normalized.to_string()
639}
640
641/// Normalize a SQLAlchemy `Column` type argument (`Integer`, `String(50)`, `db.Boolean`).
642fn sqlalchemy_type(expression: &Expression) -> Option<String> {

Callers 1

analyze_callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected