Description

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

Methods


<static> getRulesFromSQL( query, stmt ) → {object}

Description

Convert a SQL query to rules

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

MissingLibraryError, SQLParseError, UndefinedSQLOperatorError


<static> getSQL( [ stmt [, nl [, data ] ] ] ) → {module:SqlSupportPlugin.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


<static> setRulesFromSQL()

Description

Sets the builder's rules from a SQL query

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: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