Module amqp_filter

This module provides the evaluate function that allow to evaluate the predicates.

Description

This module provides the evaluate function that allow to evaluate the predicates.

Function Index

evaluate/2Evaluates a SQL92 predicate based on a property collection.

Function Details

evaluate/2

evaluate(Predicate, Properties) -> boolean() | unknown | {error, Message}

Evaluates a SQL92 predicate based on a property collection. The predicate and property collection must follow this BNF grammar specifications.

Example: predicate successfully evaluated
  amqp_filter:evaluate("ID IN (123, 456, 789)", [{"ID", 456}]).
  true
  amqp_filter:evaluate("USERNAME = 'NICK' AND AGE > 18", [{ "USERNAME", "NICK" }, { "AGE", 25 }]).
  true
  amqp_filter:evaluate("YEAR % 4 = 0 AND (NOT YEAR % 100 = 0 OR YEAR % 400 = 0)", [{ "YEAR", 2018 }]).
  false
Example: non-existent user property (more details)
  amqp_filter:evaluate("USERNAME = 'NICK'", []).
  unknown
Example: lexer or parser error
  amqp_filter:evaluate("2 @ (1, 2, 3)", []).
  {error,{1,expression_lexer,{illegal,"@"}},1}
 
  amqp_filter:evaluate("2 IN (1,)", []).
  {error,{1,expression_parser, ["syntax error before: ",["\")\""]]}}


Generated by EDoc