new SqlSupport( [ options ] )

Description

Allows to export rules as a SQL WHERE statement as well as populating the builder from an SQL query.

Parameters
Name Type Attributes Description
options object <optional>
Name Type Attributes Default Description
boolean_as_integer boolean <optional>
true

true to convert boolean values to integer in the SQL output

Methods


getRulesFromSQL( query, stmt ) → {object}

Description

Convert a SQL query to rules

Parameters
Name Type Description
query string | module:plugins.SqlSupport.SqlQuery
stmt boolean | string
Returns
Throws

MissingLibraryError, SQLParseError, UndefinedSQLOperatorError


getSQL( [ stmt [, nl [, data ] ] ] ) → {module:plugins.SqlSupport.SqlQuery}

Description

Returns rules as a SQL query

Parameters
Name Type Attributes Default Description
stmt boolean | string <optional>

use prepared statements: false, 'question_mark', 'numbered', 'numbered(@)', 'named', 'named(@)'

nl boolean <optional>
false

output with new lines

data object <optional>

current rules by default

Throws

UndefinedSQLConditionError, UndefinedSQLOperatorError


setRulesFromSQL()

Description

Sets the builder's rules from a SQL query

Details

module:plugins.SqlSupport.getRulesFromSQL

Type Definitions


SqlQuery

Properties
Name Type Description
sql string
params object
Details
object

Events


changer:getSQLField

Description

Modifies the SQL field used by a rule

Parameters
Name Type Description
field string
rule Rule
Returns

changer:getSQLFieldID

Description

Returns a filter identifier from the SQL field

Parameters
Name Type Description
field string
value *
Returns

changer:groupToSQL

Description

Modifies the SQL generated for a group

Parameters
Name Type Description
expression string
group Group
Returns

changer:parseSQLNode

Description

Custom parsing of an AST node generated by SQLParser, you can return a sub-part of the tree, or a well formed group or rule JSON

Parameters
Name Type Description
AST object

node

Returns

tree, rule or group


changer:ruleToSQL

Description

Modifies the SQL generated for a rule

Parameters
Name Type Description
expression string
rule Rule
value *
valueWrapper function

function that takes the value and adds the operator

Returns

changer:sqlGroupsDistinct

Description

Given an existing group and an AST node, determines if a sub-group must be created

Parameters
Name Type Description
create boolean

true by default if the group condition is different

group object
AST object
current int

group level

Returns

changer:sqlToGroup

Description

Modifies the group generated from the SQL expression (this is called before the group is filled with rules)

Parameters
Name Type Description
group object
AST object
Returns

changer:sqlToRule

Description

Modifies the rule generated from the SQL expression

Parameters
Name Type Description
rule object
AST object
Returns