Skip to main content

FormatQueryFinalOptions

Defined in: packages/react-querybuilder/src/types/export.ts:325

Options object curated by formatQuery and passed to a RuleGroupProcessor.

Extends

  • Required<Except<FormatQueryOptions, "context" | "valueProcessor" | "validator" | "placeholderValueName" | "ruleGroupProcessor">>

Methods

getOperators()

getOperators(field: string, misc: { fieldData: {[key: string]: unknown; className?: Classname; comparator?: string | (f: {[key: string]: unknown; className?: Classname; comparator?: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }; }): null | FlexibleOptionList<FullOperator<string>>

Defined in: packages/react-querybuilder/src/types/export.ts:167

This can be the same getOperators function passed to QueryBuilder.

The full operator object from this array, where the operator's identifying property matches the rule's operator, will be passed to the rule processor.

Parameters

ParameterType
fieldstring
misc{ fieldData: {[key: string]: unknown; className?: Classname; comparator?: string | (f: {[key: string]: unknown; className?: Classname; comparator?: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }; }
misc.fieldData{[key: string]: unknown; className?: Classname; comparator?: string | (f: {[key: string]: unknown; className?: Classname; comparator?: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }
misc.fieldData.className?Classname
misc.fieldData.comparator?string | (f: {[key: string]: unknown; className?: Classname; comparator?: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean
misc.fieldData.defaultOperator?string
misc.fieldData.defaultValue?any
misc.fieldData.disabled?boolean
misc.fieldData.id?string
misc.fieldData.inputType?null | InputType
misc.fieldData.labelstring
misc.fieldData.namestring
misc.fieldData.operators?FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>
misc.fieldData.placeholder?string
misc.fieldData.validator?RuleValidator
misc.fieldData.valuestring
misc.fieldData.valueEditorType?ValueEditorType | (operator: string) => ValueEditorType
misc.fieldData.values?FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>
misc.fieldData.valueSources?ValueSources | (operator: string) => ValueSources

Returns

null | FlexibleOptionList<FullOperator<string>>

Inherited from

Required.getOperators

Properties

concatOperator

concatOperator: "+" | string & { } | "||" | "CONCAT"

Defined in: packages/react-querybuilder/src/types/export.ts:251

Operator to use when concatenating wildcard characters and field names in "sql" format. The ANSI standard is ||, while SQL Server uses +. MySQL does not implement a concatenation operator by default, and therefore requires use of the CONCAT function.

If concatOperator is set to "CONCAT" (case-insensitive), the CONCAT function will be used. Note that Oracle SQL does not support more than two values in the CONCAT function, so this option should not be used in that context. The default setting ("||") is already compatible with Oracle SQL.

Default

'||'

Inherited from

Required.concatOperator


fallbackExpression

fallbackExpression: string

Defined in: packages/react-querybuilder/src/types/export.ts:176

This string will be inserted in place of invalid groups for non-JSON formats. Defaults to '(1 = 1)' for "sql"/"parameterized"/"parameterized_named" and '$and:[{$expr:true}]' for "mongodb".

Inherited from

Required.fallbackExpression


fieldIdentifierSeparator

fieldIdentifierSeparator: string

Defined in: packages/react-querybuilder/src/types/export.ts:142

When used in conjunction with the quoteFieldNamesWith option, field names will be split by this string, each part being individually processed as per the rules of the quoteFieldNamesWith configuration. The parts will then be re-joined by the same string.

A common value for this option is '.'.

A value of '' (the empty string) will disable splitting/rejoining.

Default

''

Example

formatQuery(query, {
format: 'sql',
quoteFieldNamesWith: ['[', ']'],
fieldIdentifierSeparator: '.',
})
// "[dbo].[Musicians].[First name] = 'Steve'"

Inherited from

Required.fieldIdentifierSeparator


fields

fields: {[key: string]: unknown; className?: Classname; comparator?: string | (f: {[key: string]: unknown; className?: Classname; comparator?: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }[] | OptionGroup<{[key: string]: unknown; className?: Classname; comparator?: string | (f: {[key: string]: unknown; className?: Classname; comparator?: string | ((f: { [x: string]: unknown; label: string; disabled?: boolean | undefined; name: string; value: string; id?: string | undefined; operators?: FlexibleOptionList<{ [x: string]: unknown; value?: string | undefined; label: string; disabled?: boolean | undefined; name: string; }> | undefined; ... 9 more ...; cl...; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: ... | ... | ...; label: string; name: string; value?: ... | ...; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: ... | ... | ...; label: string; name: string; value?: ... | ...; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }, operator: string) => boolean; defaultOperator?: string; defaultValue?: any; disabled?: boolean; id?: string; inputType?: null | InputType; label: string; name: string; operators?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; placeholder?: string; validator?: RuleValidator; value: string; valueEditorType?: ValueEditorType | (operator: string) => ValueEditorType; values?: FlexibleOptionList<{[key: string]: unknown; disabled?: boolean; label: string; name: string; value?: string; }>; valueSources?: ValueSources | (operator: string) => ValueSources; }>[]

Defined in: packages/react-querybuilder/src/types/export.ts:332

This can be the same FullField array passed to QueryBuilder, but really all you need to provide is the name and validator for each field.

The full field object from this array, where the field's identifying property matches the rule's field, will be passed to the rule processor.

Overrides

Required.fields


format

format: ExportFormat

Defined in: packages/react-querybuilder/src/types/export.ts:77

The ExportFormat.

Inherited from

Required.format


getParseNumberBoolean()

getParseNumberBoolean: (inputType?: null | InputType) => boolean

Defined in: packages/react-querybuilder/src/types/export.ts:333

Parameters

ParameterType
inputType?null | InputType

Returns

boolean


numberedParams

numberedParams: boolean

Defined in: packages/react-querybuilder/src/types/export.ts:208

Renders parameter placeholders as a series of sequential numbers instead of '?' like the default. This option will respect the paramPrefix option like the 'parameterized_named' format.

Default

false

Inherited from

Required.numberedParams


operatorMap

operatorMap: Partial

Defined in: packages/react-querybuilder/src/types/export.ts:262

Map of operators to their translations for the "natural_language" format. If the result can differ based on the valueSource, the key should map to an array where the second element represents the string to be used when valueSource is "field". The first element will be used in all other cases.

Inherited from

Required.operatorMap


operatorProcessor

operatorProcessor: RuleProcessor

Defined in: packages/react-querybuilder/src/types/export.ts:83

This function will be used to process the operator from each rule for query language formats. If not defined, the appropriate defaultOperatorProcessor* for the format will be used.

Inherited from

Required.operatorProcessor


paramPrefix

paramPrefix: string

Defined in: packages/react-querybuilder/src/types/export.ts:183

This string will be placed in front of named parameters (aka bind variables) when using the "parameterized_named" export format.

Default

":"

Inherited from

Required.paramPrefix


paramsKeepPrefix

paramsKeepPrefix: boolean

Defined in: packages/react-querybuilder/src/types/export.ts:200

Maintains the parameter prefix in the params object keys when using the "parameterized_named" export format. Recommended when using SQLite.

Default

false

Example

console.log(formatQuery(query, {
format: "parameterized_named",
paramPrefix: "$",
paramsKeepPrefix: true
}).params)
// { $firstName: "Stev" }
// Default (`paramsKeepPrefix` is `false`):
// { firstName: "Stev" }

Inherited from

Required.paramsKeepPrefix


parseNumbers

parseNumbers: ParseNumbersPropConfig

Defined in: packages/react-querybuilder/src/types/export.ts:220

Renders values as either number-types or unquoted strings, as appropriate and when possible. Each string-type value is evaluated against numericRegex to determine if it can be represented as a plain numeric value. If so, parseFloat is used to convert it to a number.

Inherited from

Required.parseNumbers


placeholderFieldName

placeholderFieldName: string

Defined in: packages/react-querybuilder/src/types/export.ts:226

Any rules where the field is equal to this value will be ignored.

Default

'~'

Inherited from

Required.placeholderFieldName


placeholderOperatorName

placeholderOperatorName: string

Defined in: packages/react-querybuilder/src/types/export.ts:232

Any rules where the operator is equal to this value will be ignored.

Default

'~'

Inherited from

Required.placeholderOperatorName


placeholderValueName?

optional placeholderValueName: string

Defined in: packages/react-querybuilder/src/types/export.ts:334


preserveValueOrder

preserveValueOrder: boolean

Defined in: packages/react-querybuilder/src/types/export.ts:213

Preserves the order of values for "between" and "notBetween" rules, even if a larger value comes before a smaller value (which will always evaluate to false).

Inherited from

Required.preserveValueOrder


preset

preset: SQLPreset

Defined in: packages/react-querybuilder/src/types/export.ts:255

Option presets to maximize compatibility with various SQL dialects.

Inherited from

Required.preset


quoteFieldNamesWith

quoteFieldNamesWith: string | [string, string]

Defined in: packages/react-querybuilder/src/types/export.ts:121

In the "sql", "parameterized", "parameterized_named", and "jsonata" export formats, field names will be bracketed by this string. If an array of strings is passed, field names will be preceded by the first element and succeeded by the second element.

Tip: Use fieldIdentifierSeparator to bracket identifiers individually within field names.

Default

'' // the empty string

Examples

formatQuery(query, { format: 'sql', quoteFieldNamesWith: '"' })
// `"First name" = 'Steve'`
formatQuery(query, { format: 'sql', quoteFieldNamesWith: ['[', ']'] })
// "[First name] = 'Steve'"

Inherited from

Required.quoteFieldNamesWith


quoteValuesWith

quoteValuesWith: string

Defined in: packages/react-querybuilder/src/types/export.ts:147

Character to use for quoting string values in the SQL format.

Default

'

Inherited from

Required.quoteValuesWith


ruleProcessor

ruleProcessor: RuleProcessor

Defined in: packages/react-querybuilder/src/types/export.ts:94

This function will be used to process each rule. If not defined, the appropriate defaultRuleProcessor* for the given format will be used.

Inherited from

Required.ruleProcessor


translations

translations: Partial<Record<NLTranslationKey, string>>

Defined in: packages/react-querybuilder/src/types/export.ts:276

Translatable strings used by the "natural_language" format.

Inherited from

Required.translations


validateRule

validateRule: FormatQueryValidateRule

Defined in: packages/react-querybuilder/src/types/export.ts:337


validationMap

validationMap: ValidationMap

Defined in: packages/react-querybuilder/src/types/export.ts:338


validator?

optional validator: QueryValidator

Defined in: packages/react-querybuilder/src/types/export.ts:336


valueProcessor

valueProcessor: ValueProcessorByRule

Defined in: packages/react-querybuilder/src/types/export.ts:335


wordOrder

wordOrder: ConstituentWordOrderString | "svo" | "sov" | "osv" | "ovs" | "vso" | "vos" | { } & string

Defined in: packages/react-querybuilder/src/types/export.ts:272

Constituent word order for the "natural_language" format. Can be abbreviated like "SVO" or spelled out like "subject-verb-object".

  • Subject = field
  • Verb = operator
  • Object = value

Inherited from

Required.wordOrder


caution

API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.