MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / execute_into_statement

Function execute_into_statement

crates/gitql-engine/src/engine_output_into.rs:8–48  ·  view source on GitHub ↗
(
    statement: &IntoStatement,
    gitql_object: &mut GitQLObject,
)

Source from the content-addressed store, hash-verified

6use gitql_core::values::Value;
7
8pub(crate) fn execute_into_statement(
9 statement: &IntoStatement,
10 gitql_object: &mut GitQLObject,
11) -> Result<(), String> {
12 let mut buffer = String::new();
13
14 let line_terminated_by = &statement.lines_terminated;
15 let field_terminated_by = &statement.fields_terminated;
16 let enclosing = &statement.enclosed;
17
18 // Headers
19 let header = gitql_object.titles.join(field_terminated_by);
20 buffer.push_str(&header);
21 buffer.push_str(line_terminated_by);
22
23 // Rows of the main group
24 if let Some(main_group) = gitql_object.groups.first() {
25 for row in &main_group.rows {
26 let row_values: Vec<String> = row
27 .values
28 .iter()
29 .map(|r| value_to_string_with_optional_enclosing(r, enclosing))
30 .collect();
31 buffer.push_str(&row_values.join(field_terminated_by));
32 buffer.push_str(line_terminated_by);
33 }
34 }
35
36 let file_result = File::create(statement.file_path.clone());
37 if let Err(error) = file_result {
38 return Err(error.to_string());
39 }
40
41 let mut file = file_result.ok().unwrap();
42 let write_result = file.write_all(buffer.as_bytes());
43 if let Err(error) = write_result {
44 return Err(error.to_string());
45 }
46
47 Ok(())
48}
49
50#[inline(always)]
51#[allow(clippy::borrowed_box)]

Callers 1

execute_statementFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…