@@ -14,6 +14,22 @@ const OPERATORS = new Set([
1414 'ALL' , 'AND' , 'ANY' , 'BETWEEN' , 'EXISTS' , 'IN' , 'IN' , 'LIKE' , 'NOT' , 'OR' , 'SOME'
1515] ) ;
1616
17+ /**
18+ * Number of operands used with an SQL operator.
19+ */
20+ const OPERAND_COUNT = new Map ( [
21+ // arithmetic operators
22+ [ '+' , 2 ] , [ '-' , 2 ] , [ '*' , 2 ] , [ '/' , 2 ] , [ '%' , 2 ] ,
23+ // bitwise operators
24+ [ '&' , 2 ] , [ '|' , 2 ] , [ '^' , 2 ] ,
25+ // comparision operators
26+ [ '=' , 2 ] , [ '>' , 2 ] , [ '<' , 2 ] , [ '>=' , 2 ] , [ '<=' , 2 ] , [ '<>' , 2 ] ,
27+ // compound operators
28+ [ '+=' , 2 ] , [ '-=' , 2 ] , [ '*=' , 2 ] , [ '/=' , 2 ] , [ '%=' , 2 ] , [ '&=' , 2 ] , [ '^=' , 2 ] , [ '|=' , 2 ] ,
29+ // logical operators
30+ [ 'ALL' , 2 ] , [ 'AND' , 2 ] , [ 'ANY' , 2 ] , [ 'BETWEEN' , 3 ] , [ 'EXISTS' , 1 ] , [ 'IN' , 2 ] , [ 'LIKE' , 2 ] , [ 'NOT' , 1 ] , [ 'OR' , 2 ] , [ 'SOME' , 2 ]
31+ ] ) ;
32+
1733
1834/**
1935 * Generates SQL command for CREATE TABLE.
@@ -220,6 +236,7 @@ function matchTsquery(tab, wrds, tsv='"tsvector"', opt={}) {
220236 return z ;
221237}
222238exports . OPERATORS = OPERATORS ;
239+ exports . OPERAND_COUNT = OPERAND_COUNT ;
223240exports . createTable = createTable ;
224241exports . createIndex = createIndex ;
225242exports . createView = createView ;
0 commit comments