$ open source · GPL-3.0 — need a commercial license? imqueue.com →

formatSql() function

Reformats a SQL string for logging, when SQL_PRETTIFY is on.

Signature:

export declare function formatSql(sql: string): string;

Parameters

Parameter

Type

Description

sql

string

Statement as sequelize reports it.

Returns:

string

The reformatted statement, or sql unchanged when prettifying is off.

Remarks

A pass-through when prettifying is off, so it is always safe to call. Otherwise sql-formatter does the work and a handful of substitutions tidy up what it does to Postgres-specific syntax — casts, &&, and bind-parameter markers, which the formatter would otherwise break across lines.

For logs only. It is not a parser and the result is not guaranteed to be executable.