Formatting

◐ in progress

Give each column the presentation it deserves, automatically whenever the query runs.

Formatting directives describe how one column should look - numbers, dates, booleans, text, and more - and apply every time the query runs. Right-click a column header and choose Set Formatting Override… to have SQLly write the comment for you, or type one by hand when you prefer.

Syntax

-- sqlly format: column=<name>; <rule>[; <option>...]
Spelling is strict here. Unlike the other directives, formatting needs the exact prefix -- sqlly format:: a space after -- and a colon immediately after format. --sqlly format: will not apply, and the editor will let you know.

The first segment is always column=<name>. The second is the format rule:

RuleEffectExample
number=NFixed-point with N decimals (honors thousands=, style=).number=2
date=PRender a date/time with strftime pattern P.date=%Y-%m-%d
boolean=T/FText for true / false values.boolean=Yes/No
binary=Render binary values as hex or base64.binary=hex
text=Casing: upper, lower, title, none.text=upper
mask=P/SMask the middle, keeping P leading and S trailing characters.mask=0/4
epoch=Epoch integer to date: auto, s, or ms.epoch=s
json=PExtract a JSON path from the cell.json=$.customer.name
template=TTemplated cell with pipe helpers.template={value|upper}

Trailing options: thousands=true|false and style=fixed|percent|bytes refine a number= rule.

Examples

-- sqlly format: column=Total; number=2
-- sqlly format: column=Qty; number=0; thousands=false
-- sqlly format: column=Created; date=%Y-%m-%d
-- sqlly format: column=IsActive; boolean=Yes/No
-- sqlly format: column=rate; number=1; style=percent
-- sqlly format: column=Card; mask=0/4
SELECT * FROM orders;
SQLly
A SQLly formatting directive applied to a result column
A formatting directive applied to a column, with the formatted values shown in the grid.