InfluxElixir.Client.Local.SQLBind (InfluxElixir v0.1.40)

Copy Markdown View Source

Binds the $name placeholders of a parsed query.

A $name is read as a value wherever a value may stand: a comparand, an item of an IN list, a bound of BETWEEN, a LIKE or regex pattern, an operand of an expression, a select-list constant, LIMIT or OFFSET. The parser keeps it as a node and bind/2 replaces the node with the value the engine would read for it from the request's JSON: a non-negative integer is a UInt64 ({:uint, n}), any other integer an Int64, a float a Float64, a string a Utf8; text is never substituted, so a value is data whatever it contains.

Summary

Functions

Binds a parsed query's $name placeholders to params, whose values are what the engine reads from the request (see InfluxElixir.Client.QueryParams.engine_values/1).

Checks that a statement that binds no parameters names none: a $name is the engine's planning error for a placeholder with no value.

Functions

bind(query, params)

Binds a parsed query's $name placeholders to params, whose values are what the engine reads from the request (see InfluxElixir.Client.QueryParams.engine_values/1).

A placeholder with no value is the engine's planning error; a value the placeholder's place cannot take is the engine's error for it: a time compared with a number is a type error naming the number's type (UInt64 for a non-negative integer), LIMIT takes an integer or null. A query without placeholders is returned as it is. Only the query's own clauses are bound, not its CTEs.

reject_placeholders(nodes)

@spec reject_placeholders([InfluxElixir.Client.Local.SQLWhere.node_t()]) ::
  :ok | {:error, map()}

Checks that a statement that binds no parameters names none: a $name is the engine's planning error for a placeholder with no value.