query.safeSqlSpaceCleanup() function

Collapses whitespace outside quoted literals, so a statement fits on one line.

Signature:

export function safeSqlSpaceCleanup(input: string): string;

Parameters

Parameter

Type

Description

input

string

Statement to normalise.

Returns:

string

The statement with structural whitespace collapsed to single spaces.

Remarks

Walks the string tracking whether a single quote is open, so runs of whitespace inside a literal are preserved and only structural whitespace is collapsed. Quote tracking is a simple toggle: it does not understand escaped or doubled quotes, so a literal containing one can throw the parity off.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.