compiled without any problems
This commit is contained in:
@@ -19,7 +19,7 @@ impl SyntaxParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(&self, script: &str) -> String {
|
pub fn parse(&self, script: &str, current_table: &str) -> String {
|
||||||
let mut transformed = script.to_string();
|
let mut transformed = script.to_string();
|
||||||
|
|
||||||
// Process indexed access first to avoid overlap with relationship matches
|
// Process indexed access first to avoid overlap with relationship matches
|
||||||
@@ -46,7 +46,7 @@ impl SyntaxParser {
|
|||||||
transformed
|
transformed
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extract_dependencies(&self, script: &str) -> (HashSet<String>, HashSet<String>) {
|
pub fn extract_dependencies(&self, script: &str, current_table: &str) -> (HashSet<String>, HashSet<String>) {
|
||||||
let mut tables = HashSet::new();
|
let mut tables = HashSet::new();
|
||||||
let mut columns = HashSet::new();
|
let mut columns = HashSet::new();
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ pub async fn post_table_script(
|
|||||||
|
|
||||||
// Parse and transform the script
|
// Parse and transform the script
|
||||||
let parser = SyntaxParser::new();
|
let parser = SyntaxParser::new();
|
||||||
let parsed_script = parser.parse(&request.script);
|
let parsed_script = parser.parse(&request.script, &table_def.table_name);
|
||||||
|
let (tables, columns) = parser.extract_dependencies(&request.script, &table_def.table_name);
|
||||||
|
|
||||||
// Store script in database with automatic target_table
|
// Store script in database with automatic target_table
|
||||||
let script_record = sqlx::query!(
|
let script_record = sqlx::query!(
|
||||||
@@ -72,7 +73,7 @@ pub async fn post_table_script(
|
|||||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||||
RETURNING id"#,
|
RETURNING id"#,
|
||||||
request.table_definition_id,
|
request.table_definition_id,
|
||||||
table_def.table_name, // Auto-populate target_table from table_def
|
table_def.table_name,
|
||||||
request.target_column,
|
request.target_column,
|
||||||
column_type,
|
column_type,
|
||||||
parsed_script,
|
parsed_script,
|
||||||
|
|||||||
Reference in New Issue
Block a user