# `jadpo sql`

Show the SQL a query or action sends.

Print the PostgreSQL a query compiles to (area 6): its statement, then one more for each include, however many records it is included in, each with the parameters that fill it and where their values come from. Given an action, print the statement each of its writes sends, with what each refusal raises: the failure a conflict: arm names, the not-found failure or a fault. The statements are fixed when the project is compiled, so the same query always sends the same text. The project must check without errors first. --explain, which runs the query on a disposable database and shows PostgreSQL's plan, comes later.

```text
jadpo sql [name]
```

## Arguments

- `name` (optional): The query's or action's name

## Flags

- `--explain`: Show PostgreSQL's plan (not built yet)

## On every command

- `--json`: Print data for tools instead of text
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo sql --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"sql"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# Show the statements a page query sends
jadpo sql latest_entries
# Show the statements an action's writes send
jadpo sql archive_entry
```

## Errors

- [`cli.sql_arguments`](../errors/cli.sql_arguments.md): Sql command has invalid arguments
- [`toolchain.not_built_yet`](../errors/toolchain.not_built_yet.md): Operation is declared but not built yet
- [`toolchain.project_not_found`](../errors/toolchain.project_not_found.md): Project could not be found
