ValueProcessorOptions
Options object for ValueProcessorByRule functions.
Extends
Properties
concatOperator?
optional
concatOperator:string
& {} | "||" |"+"
|"CONCAT"
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
FormatQueryOptions
.concatOperator
Defined in
packages/react-querybuilder/src/types/importExport.ts:193
context?
optional
context:Record
<string
,any
>
Inherited from
Defined in
packages/react-querybuilder/src/types/importExport.ts:199
escapeQuotes?
optional
escapeQuotes:boolean
Defined in
packages/react-querybuilder/src/types/importExport.ts:207
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".
Inherited from
FormatQueryOptions
.fallbackExpression
Defined in
packages/react-querybuilder/src/types/importExport.ts:129
fieldData?
optional
fieldData:FullField
<string
,string
,string
,Option
<string
>,Option
<string
>>
The full field object, if fields
was provided in the
formatQuery options parameter.
Defined in
packages/react-querybuilder/src/types/importExport.ts:212
fieldIdentifierSeparator?
optional
fieldIdentifierSeparator:string
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
FormatQueryOptions
.fieldIdentifierSeparator
Defined in
packages/react-querybuilder/src/types/importExport.ts:95
fieldParamNames?
optional
fieldParamNames:Record
<string
,string
[]>
Included for the "parameterized_named" format only. Keys of this object represent field names and values represent the current list of parameter names for that field based on the query rules processed up to that point. Use this list to ensure that parameter names generated by the custom rule processor are unique.
Defined in
packages/react-querybuilder/src/types/importExport.ts:219
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.
Inherited from
Defined in
packages/react-querybuilder/src/types/importExport.ts:113
format?
optional
format:ExportFormat
The ExportFormat.
Inherited from
Defined in
packages/react-querybuilder/src/types/importExport.ts:43
getNextNamedParam()?
optional
getNextNamedParam: (field
:string
) =>string
Included for the "parameterized_named" format only. Call this function with a field name to get a unique parameter name, as yet unused during query processing.
Parameters
Parameter | Type |
---|---|
field | string |
Returns
string
Defined in
packages/react-querybuilder/src/types/importExport.ts:224
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
Inherited from
FormatQueryOptions
.numberedParams
Defined in
packages/react-querybuilder/src/types/importExport.ts:161
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
":"
Inherited from
FormatQueryOptions
.paramPrefix
Defined in
packages/react-querybuilder/src/types/importExport.ts:136
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" }
Inherited from
FormatQueryOptions
.paramsKeepPrefix
Defined in
packages/react-querybuilder/src/types/importExport.ts:153
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.
Inherited from
FormatQueryOptions
.parseNumbers
Defined in
packages/react-querybuilder/src/types/importExport.ts:168
placeholderFieldName?
optional
placeholderFieldName:string
Any rules where the field is equal to this value will be ignored.
Default
'~'
Inherited from
FormatQueryOptions
.placeholderFieldName
Defined in
packages/react-querybuilder/src/types/importExport.ts:174
placeholderOperatorName?
optional
placeholderOperatorName:string
Any rules where the operator is equal to this value will be ignored.
Default
'~'
Inherited from
FormatQueryOptions
.placeholderOperatorName
Defined in
packages/react-querybuilder/src/types/importExport.ts:180
preset?
optional
preset:SQLPreset
Option presets to maximize compatibility with various SQL dialects.
Inherited from
Defined in
packages/react-querybuilder/src/types/importExport.ts:197
quoteFieldNamesWith?
optional
quoteFieldNamesWith:string
| [string
,string
]
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
FormatQueryOptions
.quoteFieldNamesWith
Defined in
packages/react-querybuilder/src/types/importExport.ts:74
quoteValuesWith?
optional
quoteValuesWith:string
Character to use for quoting string values in the SQL format.
Default
'
Inherited from
FormatQueryOptions
.quoteValuesWith
Defined in
packages/react-querybuilder/src/types/importExport.ts:100
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.
Inherited from
FormatQueryOptions
.ruleProcessor
Defined in
packages/react-querybuilder/src/types/importExport.ts:55
validator?
optional
validator:QueryValidator
Validator function for the entire query. Can be the same function passed
as validator
prop to QueryBuilder.
Inherited from
Defined in
packages/react-querybuilder/src/types/importExport.ts:105
valueProcessor?
optional
valueProcessor: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.
Overrides
FormatQueryOptions
.valueProcessor
Defined in
packages/react-querybuilder/src/types/importExport.ts:206
wrapValueWith?
optional
wrapValueWith: [string
,string
]
Additional prefix and suffix characters to wrap the value in. Useful for augmenting the default value processor results with special syntax (e.g., for dates or function calls).
Defined in
packages/react-querybuilder/src/types/importExport.ts:230
Methods
getOperators()?
optional
getOperators(field
:string
,misc
: {fieldData
:FullField
<string
,string
,string
,Option
<string
>,Option
<string
>>; }):null
|FlexibleOptionList
<FullOperator
<string
>>
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
Parameter | Type |
---|---|
field | string |
misc | { fieldData : FullField <string , string , string , Option <string >, Option <string >>; } |
misc.fieldData | FullField <string , string , string , Option <string >, Option <string >> |
Returns
null
| FlexibleOptionList
<FullOperator
<string
>>
Inherited from
FormatQueryOptions
.getOperators
Defined in
packages/react-querybuilder/src/types/importExport.ts:120
API documentation is generated from the latest commit on the main
branch. It may be somewhat inconsistent with official releases of React Query Builder.