Skip to main content

find_variable_at_position

Function find_variable_at_position 

Source
pub(crate) fn find_variable_at_position(
    sql: &str,
    offset: usize,
) -> Option<(String, usize, usize)>
Expand description

Find the variable reference (if any) that contains the given byte offset.

Scans sql using the same context-awareness rules as resolve_variables (skipping strings, comments, dollar-quotes, type casts) and checks whether offset falls inside a variable reference.

ยงReturns

(name, byte_offset_of_colon, byte_len) if the offset is inside a :name, :'name', or :"name" reference outside of strings/comments. None otherwise.