MCPcopy Index your code
hub / github.com/JasonShin/sqlx-ts / parse_sql_file

Function parse_sql_file

src/parser/sql_parser.rs:13–26  ·  view source on GitHub ↗
(path: &PathBuf)

Source from the content-addressed store, hash-verified

11};
12
13pub fn parse_sql_file(path: &PathBuf) -> Result<(HashMap<PathBuf, Vec<SQL>>, Handler)> {
14 let contents = fs::read_to_string(path)?;
15 let cm: Lrc<SourceMap> = Default::default();
16 let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(cm.clone()));
17
18 let mut sqls_map: HashMap<PathBuf, Vec<SQL>> = HashMap::new();
19 let sqls = extract_sql_queries_from_file(&contents, path)?;
20
21 if !sqls.is_empty() {
22 sqls_map.insert(path.clone(), sqls);
23 }
24
25 Ok((sqls_map, handler))
26}
27
28/// Extract SQL queries from raw SQL file content
29/// Supports multiple queries separated by semicolons and annotations

Callers 1

parse_sourceFunction · 0.85

Calls 1

Tested by

no test coverage detected