Skip to main content

FormatQueryOptions

Options object shape for formatQuery.

Extended by

Properties

fallbackExpression?

optional fallbackExpression: string

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".

Source

packages/react-querybuilder/src/types/importExport.ts:80


fields?

optional fields: FlexibleOptionList <FullField<string, string, string, Option<string>, Option<string>>>

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.

Source

packages/react-querybuilder/src/types/importExport.ts:74


format?

optional format: ExportFormat

The ExportFormat.

Source

packages/react-querybuilder/src/types/importExport.ts:31


numberedParams?

optional numberedParams: boolean

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

Source

packages/react-querybuilder/src/types/importExport.ts:112


paramPrefix?

optional paramPrefix: string

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

Default

":"

Source

packages/react-querybuilder/src/types/importExport.ts:87


paramsKeepPrefix?

optional paramsKeepPrefix: boolean

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" }

Source

packages/react-querybuilder/src/types/importExport.ts:104


parseNumbers?

optional parseNumbers: boolean

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.

Source

packages/react-querybuilder/src/types/importExport.ts:119


placeholderFieldName?

optional placeholderFieldName: string

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

Default

'~'

Source

packages/react-querybuilder/src/types/importExport.ts:125


placeholderOperatorName?

optional placeholderOperatorName: string

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

Default

'~'

Source

packages/react-querybuilder/src/types/importExport.ts:131


quoteFieldNamesWith?

optional quoteFieldNamesWith: string | [string, string]

In the "sql"/"parameterized"/"parameterized_named" 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. A common value for this option is the backtick ('`').

Default

'' // the empty string

Examples

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

Source

packages/react-querybuilder/src/types/importExport.ts:61


quoteValuesWith?

optional quoteValuesWith: string

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

Default

'''

Source

packages/react-querybuilder/src/types/importExport.ts:136


ruleProcessor?

optional ruleProcessor: RuleProcessor

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

Source

packages/react-querybuilder/src/types/importExport.ts:43


validator?

optional validator: QueryValidator

Validator function for the entire query. Can be the same function passed as validator prop to QueryBuilder.

Source

packages/react-querybuilder/src/types/importExport.ts:66


valueProcessor?

optional valueProcessor: ValueProcessorLegacy | ValueProcessorByRule

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

Source

packages/react-querybuilder/src/types/importExport.ts:37


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.