| 177 | } |
| 178 | |
| 179 | fn evaluate_describe_query( |
| 180 | env: &mut Environment, |
| 181 | describe_query: DescribeQuery, |
| 182 | ) -> Result<EvaluationResult, String> { |
| 183 | let table_fields = env |
| 184 | .schema |
| 185 | .tables_fields_names |
| 186 | .get(&describe_query.table_name.as_str()) |
| 187 | .unwrap(); |
| 188 | |
| 189 | let mut gitql_object = GitQLObject::default(); |
| 190 | gitql_object.titles.push("field".to_owned()); |
| 191 | gitql_object.titles.push("type".to_owned()); |
| 192 | |
| 193 | let mut rows: Vec<Row> = Vec::with_capacity(table_fields.len()); |
| 194 | for field in table_fields { |
| 195 | let value = env.schema.tables_fields_types.get(field).unwrap(); |
| 196 | rows.push(Row { |
| 197 | values: vec![ |
| 198 | Box::new(TextValue::new(field.to_owned().to_owned())), |
| 199 | Box::new(TextValue::new(value.literal())), |
| 200 | ], |
| 201 | }) |
| 202 | } |
| 203 | |
| 204 | gitql_object.groups.push(Group { rows }); |
| 205 | Ok(EvaluationResult::SelectedGroups(gitql_object)) |
| 206 | } |
| 207 | |
| 208 | fn evaluate_show_tables_query(env: &mut Environment) -> Result<EvaluationResult, String> { |
| 209 | let tables = env.schema.tables_fields_names.keys(); |