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.
-- @colrender created_at, last_login_at / instant / unit=mills
select * from users;For integer columns:
instant: Optional parameters:
unit(s/ms/ns)andtz(string).unitdefaults toms.tzdefaults 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:
linewidthdefaults to5, alias tolw.separatordefaults to" ", alias tosep.
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.
0x00is treated as false, and all other values as true.Example:
@colrender bytescol / boolean.string:
encodingdefaults toutf-8, alias toenc.
Example:
@colrender bytescol / string / encoding=utf8.hexstring:
lowercasedefaults tofalse, alias tolc.separatordefaults to" ", alias tosep.linewidthdefaults to16, alias tolw.
Example:
@colrender bytescol / hex / lowercase=true.bitmap:
linewidthdefaults to5, alias tolw.separatordefaults to" ", alias tosep.
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");
});