Open
Conversation
change to surface file names
Author
|
test |
Changing to fix error that caused only the first file to be saved.
davydmaker
requested changes
Jan 13, 2026
Member
davydmaker
left a comment
There was a problem hiding this comment.
thanks for the contribution ❤️
| DEFAULT_SQL_CONDITIONS = ["DROP TABLE", "CREATE TABLE IF NOT EXISTS", "CREATE VIEW", "CREATE FUNCTION", "CREATE PROCEDURE"] | ||
|
|
||
| def extract_name(line): | ||
| # Regex patterns to match table/view/function/procedure names |
Member
There was a problem hiding this comment.
Suggested change
| # Regex patterns to match table/view/function/procedure names |
Comment on lines
+17
to
+27
| r'CREATE TABLE (\w+)', # Match CREATE TABLE statements | ||
| r'CREATE VIEW (\w+)', # Match CREATE VIEW statements | ||
| r'CREATE FUNCTION (\w+)', # Match CREATE FUNCTION statements | ||
| r'CREATE PROCEDURE (\w+)', # Match CREATE PROCEDURE statements | ||
| r'DROP TABLE (\w+)', # Match DROP TABLE statements | ||
| ] | ||
|
|
||
| for pattern in patterns: | ||
| match = re.search(pattern, line) | ||
| if match: | ||
| return match.group(1) |
Member
There was a problem hiding this comment.
By enhancing the regex, we can support variations in spacing, IF NOT EXISTS statements, names with/without quotes, and case sensitivity:
Suggested change
| r'CREATE TABLE (\w+)', # Match CREATE TABLE statements | |
| r'CREATE VIEW (\w+)', # Match CREATE VIEW statements | |
| r'CREATE FUNCTION (\w+)', # Match CREATE FUNCTION statements | |
| r'CREATE PROCEDURE (\w+)', # Match CREATE PROCEDURE statements | |
| r'DROP TABLE (\w+)', # Match DROP TABLE statements | |
| ] | |
| for pattern in patterns: | |
| match = re.search(pattern, line) | |
| if match: | |
| return match.group(1) | |
| r'CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:`?(\w+)`?|"(\w+)"|\'(\w+)\')', | |
| r'CREATE\s+VIEW\s+(?:`?(\w+)`?|"(\w+)"|\'(\w+)\')', | |
| r'CREATE\s+FUNCTION\s+(?:`?(\w+)`?|"(\w+)"|\'(\w+)\')', | |
| r'CREATE\s+PROCEDURE\s+(?:`?(\w+)`?|"(\w+)"|\'(\w+)\')', | |
| r'DROP\s+TABLE\s+(?:`?(\w+)`?|"(\w+)"|\'(\w+)\')', | |
| ] | |
| for pattern in patterns: | |
| match = re.search(pattern, line, re.IGNORECASE) | |
| if match: | |
| return next((g for g in match.groups() if g), None) |
| current_content = [] | ||
| condition_hit_count = 0 | ||
| if current_content: | ||
| # Save the current content to the previous file name |
Member
There was a problem hiding this comment.
Suggested change
| # Save the current content to the previous file name |
| save_file(current_content, output_dir, current_file_name) | ||
| file_count += 1 | ||
|
|
||
| # Set the new file name based on the extracted name |
Member
There was a problem hiding this comment.
Suggested change
| # Set the new file name based on the extracted name |
| file_count += 1 | ||
|
|
||
| # Set the new file name based on the extracted name | ||
| current_file_name = name if name else f"file_{file_count}" # Fallback if name extraction fails |
Member
There was a problem hiding this comment.
Suggested change
| current_file_name = name if name else f"file_{file_count}" # Fallback if name extraction fails | |
| current_file_name = name if name else f"file_{file_count}" |
Comment on lines
+81
to
+82
| current_content = [] # Reset current content for the new file | ||
| condition_hit_count = 0 # Reset hit count |
Member
There was a problem hiding this comment.
Suggested change
| current_content = [] # Reset current content for the new file | |
| condition_hit_count = 0 # Reset hit count | |
| current_content = [] | |
| condition_hit_count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
change to surface file names