MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / json_schema_from_entity_column

Function json_schema_from_entity_column

src/schema/json.rs:40–61  ·  view source on GitHub ↗
(column: E::Column)

Source from the content-addressed store, hash-verified

38}
39
40fn json_schema_from_entity_column<E>(column: E::Column) -> Value
41where
42 E: EntityTrait,
43{
44 let mut obj = Map::new();
45
46 let column_def = column.def();
47 obj.insert("name".to_owned(), Value::String(column.to_string()));
48 obj.insert(
49 "type".to_owned(),
50 type_def_from_column_def(&column_def.col_type),
51 );
52 obj.insert("nullable".to_owned(), Value::Bool(column_def.null));
53 if column_def.unique {
54 obj.insert("unique".to_owned(), Value::Bool(true));
55 }
56 if let Some(comment) = column_def.comment {
57 obj.insert("comment".to_owned(), Value::String(comment));
58 }
59
60 Value::Object(obj)
61}
62
63fn type_def_from_column_def(column_type: &ColumnType) -> Value {
64 match column_type {

Callers

nothing calls this directly

Calls 4

type_def_from_column_defFunction · 0.85
newFunction · 0.50
defMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected