DbQueryTableColumnComparison - do-/node-doix-db GitHub Wiki

DbQueryTableColumnComparison is a class representing simplest SQL comparison predicates:

<table name>.<column name> <comp op> <value>

For IN and NOT IN operators:

  • when an empty array is passed as value, table and column names are ignored and the whole expression is replaced by 0=1 for IN (in empty set == false) and 0=0 for NOT IN
  • a {sql, params} object can be used as value: in this case, the ...IN (${sql}) fragment is generated and params are bound appropriately.
    • a single column DbQuery is suitable on this occasion.

Properties

Name Type Description
table DbQueryTable The table this predicate is associated to
column DbColumn The column which value is compared (left side)
op String Comparison operator name, uppercase
sql String The SQL fragment to be interpolated in the query
params Array The list of parameters corresponding to all ? placeholders in sql

Constructor

const myComp = new DbQueryTableColumnComparison (myQueryTable, 'id', 'IN', [1, 2])

Using DbQueryTable's createColumnComparison method is encouraged.

const myComp = myQueryTable.createColumnComparison ('id', 'IN', [1, 2])

Parameters

Name Type Description
table DbQueryTable The table this predicate is associated to
name String column's name.
op String Comparison operator name, any case
value any The value(s) the column is compared to. Ignored for unary operators.

Methods

setParams

This internal method, called from the constructor, sets sql and params based on incoming op and value.

⚠️ **GitHub.com Fallback** ⚠️