pattern_to_sql_exclude#

barecat.util.glob_helper.pattern_to_sql_exclude(pattern)[source]#

Convert exclude pattern to SQL condition, if possible.

Returns (sql_expr, params) tuple, or None if pattern can’t be efficiently expressed in SQL and should be handled by Python.

Handles common patterns: - ‘.ext’ (root only) -> parent = ‘’ AND path GLOB ‘.ext’ - ‘dir/.ext’ (direct children) -> parent = ‘dir’ AND path GLOB ‘dir/.ext’ - ‘/*.ext’ (any depth) -> path GLOB ‘*.ext’ - ‘dir/’ (entire subtree) -> path GLOB ‘dir/’ - ‘*/dir/**’ (dir at any depth) -> path GLOB ‘/dir/’ OR path GLOB ‘dir/*