Formatting
◐ in progressGive 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:
| Rule | Effect | Example |
|---|---|---|
number=N | Fixed-point with N decimals (honors thousands=, style=). | number=2 |
date=P | Render a date/time with strftime pattern P. | date=%Y-%m-%d |
boolean=T/F | Text 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/S | Mask the middle, keeping P leading and S trailing characters. | mask=0/4 |
epoch= | Epoch integer to date: auto, s, or ms. | epoch=s |
json=P | Extract a JSON path from the cell. | json=$.customer.name |
template=T | Templated 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;
