Parser

Parser

Parse SQL and populate onto a Select query object

Constructor

new Parser(query)

Create a new instance

Source:
Parameters:
Name Type Description
query Select

A Select object on which to build parsed conditions

Methods

(private) _extractSubqueries(sql) → {Object}

Before splitting into SQL clauses, extract some regex-able subqueries

Source:
Parameters:
Name Type Description
sql String

The unparsed sql string

Returns:
Type:
Object

An array with new sql and subqueries

(private) _handleConditions(type, clause)

Build a conditions list

Source:
Parameters:
Name Type Description
type String

Either WHERE or HAVING

clause String

The expressions following the type keyword

(private) _handleCrossJoin(clause)

Handle CROSS JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the CROSS JOIN

(private) _handleFrom(clause)

Handle table names

Source:
Parameters:
Name Type Description
clause String

The clause after the FROM

(private) _handleFullJoin(clause)

Handle FULL JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the FULL JOIN

(private) _handleFullOuterJoin(clause)

Handle FULL OUTER JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the FULL OUTER JOIN

(private) _handleGroupBy(clause)

Handle GROUP BY statements

Source:
Parameters:
Name Type Description
clause String

The clauses after the GROUP BY

(private) _handleHaving(clause)

Handle HAVING statements

Source:
Parameters:
Name Type Description
clause String

All the conditions after HAVING

(private) _handleInnerJoin(clause)

Handle INNER JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the INNER JOIN

(private) _handleLeftJoin(clause)

Handle LEFT JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the LEFT JOIN

(private) _handleLeftOuterJoin(clause)

Handle LEFT OUTER JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the LEFT OUTER JOIN

(private) _handleLimit(clause)

Handle LIMIT statements including "LIMIT #" and "LIMIT #, #"

Source:
Parameters:
Name Type Description
clause String

The clause after the LIMIT

(private) _handleOffset(clause)

Handle OFFSET statements

Source:
Parameters:
Name Type Description
clause String

The number after the OFFSET

(private) _handleOrderBy(clause)

Handle ORDER BY statements

Source:
Parameters:
Name Type Description
clause String

The clause after the ORDER BY

(private) _handleRightJoin(clause)

Handle RIGHT JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the RIGHT JOIN

(private) _handleRightOuterJoin(clause)

Handle RIGHT OUTER JOIN statements

Source:
Parameters:
Name Type Description
clause String

The clause after the RIGHT OUTER JOIN

(private) _handleSelect(clause)

Handle SQL_CALC_FOUND_ROWS and column names

Source:
Parameters:
Name Type Description
clause String

The clause after the SELECT

(private) _handleWhere(clause)

Handle WHERE conditions

Source:
Parameters:
Name Type Description
clause String

All the conditions after WHERE

(private) _injectSubqueries(subqueries)

Inject column subqueries back into this object

Source:
Parameters:
Name Type Description
subqueries Object

The lookup of extracted subqueries

(private) _split(sql) → {Array.<String>}

Split SQL into clauses (used by ::parse())

Source:
Parameters:
Name Type Description
sql String

The SQL to split

Returns:
Type:
Array.<String>

(private) _stripComments(sql) → {String}

Strip single-line and multi-line comment blocks

Source:
Parameters:
Name Type Description
sql String

The SQL string

Returns:
Type:
String

parse(rawSql) → {Boolean}

Get a QuickSelect object representing the given SQL SELECT statement

Source:
Parameters:
Name Type Description
rawSql String

The raw SQL for the SELECT statement

Returns:
Type:
Boolean