Processes SQL template literals with automatic value escaping and performance optimization.
Template literal processor that interleaves static strings with escaped dynamic values. Implements four performance tiers based on interpolation count: specialized paths for 0, 1, 2-3, and 4+ values optimize for common usage patterns.
Performance Optimization: Different algorithms by value count:
Security: All dynamic values pass through escapeSql() automatically. Whitespace: Trims leading/trailing whitespace only when detected (performance).
Static template string parts
Rest
...values: unknown[]Dynamic values to interpolate and escape
Complete SQL query with escaped values and trimmed whitespace
// Zero values - direct return path
processSQLTemplate`SELECT * FROM users` // → "SELECT * FROM users"
// Single value - concatenation path
processSQLTemplate`SELECT * FROM ${tableName}` // → "SELECT * FROM users"
// Multiple values - optimized for count
processSQLTemplate`SELECT * FROM ${table} WHERE status = '${status}' LIMIT ${limit}`
// → "SELECT * FROM orders WHERE status = 'pending' LIMIT 10"
SQL template literal with automatic escaping and performance optimization.
Template tag that builds SQL queries by interpolating values with automatic character escaping. Implements tiered performance optimizations based on interpolation count (0, 1, 2-3, 4+ values).
Security Boundary: Escapes string literal breakouts and binary injection. Does NOT prevent logical injection patterns. Use parameterized queries for complete protection.
Performance: Four optimization tiers scale from simple concatenation to pre-sized array joins. Conditional whitespace trimming avoids unnecessary work.
Example
Example
Example
Example
Example