Skip to content

SQL Column Rendering

Currently supported column types for custom rendering:

  • integer
  • bytes

For SQL Editor

Custom rendering for integer and bytes columns can be set using comment directives with the format:@colrender colname[,colname ...] / kind [/ key=val[; key=val ...] ]

Typing @colr will trigger the Monaco Editor's snippet autocomplete.

sql
-- @colrender created_at, last_login_at / instant / unit=mills
select * from users;

For integer columns:

  • instant: Optional parameters: unit(s/ms/ns) and tz(string).

    • unit defaults to ms.
    • tz defaults to the computer's local time zone, and can be any IANA time zone name.

    Example: @colrender intcol / instant / unit=s.

  • bool: 0 is treated as false, and all other values as true.

    Example: @colrender intcol / bool.

  • enum: Any value in the options that can be safely converted to an integer is considered an enum item.

    Example: @colrender intcol / enum / a=1; b=2; c=3.

  • bitmap:

    • linewidth defaults to 5, alias to lw.
    • separator defaults to " ", alias to sep.

    Example: @colrender intcol / bitmap / linewidth=5; separator=" ".

For Bytes columns:

  • uuid:The value length must be 16.

    Example: @colrender bytescol / uuid.

  • boolean:The value length must be 1. 0x00 is treated as false, and all other values as true.

    Example: @colrender bytescol / boolean.

  • string:

    • encoding defaults to utf-8, alias to enc.

    Example: @colrender bytescol / string / encoding=utf8.

  • hexstring:

    • lowercase defaults to false, alias to lc.
    • separator defaults to " ", alias to sep.
    • linewidth defaults to 16, alias to lw.

    Example: @colrender bytescol / hex / lowercase=true.

  • bitmap:

    • linewidth defaults to 5, alias to lw.
    • separator defaults to " ", alias to sep.

    Example: @colrender bytescol / bitmap / linewidth=5; separator=" ".

For TypeScript SQL Shell

sqlshell<IDBSqlite, typeof SqliteDialect>((ctx, db, dialect) => {
	db.users
		.select({})
		.export(ctx)
		.variants
        .instant(["created_at", "last_login_at"], { unit: "mills" })
		.bitmap("permissions");
});