Skip to main content

Module parser

Module parser 

Source
Expand description

SQL parsing utilities: statement splitting, FK extraction, source table detection.

Structs§

ForeignKeyInfo
Foreign key relationship from one column to another table/column.

Functions§

detect_source_table
Detect whether a SQL query targets a single table and return that table name.
detect_statements
Split a SQL string into individual statements, respecting quoted strings and comments.
extract_identifier
Extract an identifier (possibly quoted with " or `) from the start of s. Returns (identifier, rest_of_string).
extract_table_name
Extract a single table name from the beginning of text. Handles double-quoted and backtick-quoted names. Stops at whitespace, ;, or end of string.
find_from_keyword
Find the position of the table name (the text after “FROM “) in sql. Returns the byte offset into sql of the text immediately after FROM and whitespace.
parse_foreign_keys
Parse foreign key relationships from a CREATE TABLE SQL statement.
strip_comments
Remove SQL comments (both line -- and block /* */) from a SQL string.
unquote
Remove surrounding quotes from a column name if present.