# query.sql() function · @imqueue/pg-sequelize

Source: https://imqueue.org/api/pg-sequelize/latest/pg-sequelize.query.sql/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-sequelize 4.2.0 — generated reference, not hand-written

Normalises a SQL string: one-lined, whitespace collapsed, ending in a single semicolon.

**Signature:**

```typescript
export function sql(sqlQuery: string | TemplateStringsArray, ...values: any[]): string;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| sqlQuery | string \| TemplateStringsArray | A complete statement, or a template with no substitutions. |
| values | any\[\] | Template substitutions, which are not supported. |


**Returns:**

string

The statement on one line, terminated with exactly one `;`.

## Exceptions

TypeError when used as a template tag with substitutions.

## Remarks

Usable as a plain function or as a template tag, the tag form being there so an editor highlights the SQL. It does NOT interpolate: a tag carrying substitutions throws, because the substituted values cannot be reached from here and the statement would come out mangled: tagging `SELECT ... WHERE id = ${id}` used to yield `... id = ,`. Bind parameters are the answer, and they are also the only safe one.

Whitespace inside single-quoted literals is preserved; only whitespace outside them is collapsed.

## Example


```typescript
const statement = sql`
    SELECT id, name
      FROM "Lead"
     WHERE status = $1
`;
// SELECT id, name FROM "Lead" WHERE status = $1;
await database().query(statement, { bind: [status] });
```

