Skip to main content

IsReservedWordFunction

The type of the optional isReservedWord field on SerializerExtension, used to decide which bare identifiers must be escaped (double-quoted) when a dialect has its own reserved-word list. Relevant only to authors of a dialect/adapter package — not to everyday query building.

type IsReservedWordFunction = (ctx: SerializeContext, s: string) => boolean;

Parameters

ParameterTypeDescription
ctxSerializeContextThe active serialization context for the whole .generate() call.
sstringThe bare identifier being checked (e.g. a field or alias name).

Return true to have the builder escape s (double-quote it) when rendering; false to leave it unescaped. Field, GroupColumn, and OrderColumn all consult this via ctx.isReservedWord(...) for their unqualified field/alias names.

import { SerializerRegistry } from '@sqb/builder';

SerializerRegistry.register({
dialect: 'my-dialect',
isReservedWord(ctx, word) {
return MY_DIALECT_RESERVED_WORDS.has(word.toLowerCase());
},
});

See also