compiled without any problems

This commit is contained in:
filipriec
2025-03-15 21:16:14 +01:00
parent d0bc41978d
commit ff185549b4
2 changed files with 5 additions and 4 deletions

View File

@@ -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();
// Process indexed access first to avoid overlap with relationship matches
@@ -46,7 +46,7 @@ impl SyntaxParser {
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 columns = HashSet::new();

View File

@@ -62,7 +62,8 @@ pub async fn post_table_script(
// Parse and transform the script
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
let script_record = sqlx::query!(
@@ -72,7 +73,7 @@ pub async fn post_table_script(
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id"#,
request.table_definition_id,
table_def.table_name, // Auto-populate target_table from table_def
table_def.table_name,
request.target_column,
column_type,
parsed_script,