Boolean Functions and Operators​

bool Boolean type
bool or bool Logical disjunction.
bool and bool Logical conjunction.
not bool Logical negation.
= != ?= ?!= < > <= >= Comparison operators
all() Generalized boolean and applied to the set of values.
any() Generalized boolean or applied to the set of values.

type

bool

Boolean - 图1

bool

A boolean type with possible values of true and false.

EdgeQL has case-insensitive keywords and that includes the boolean literals:


1. select (True, true, TRUE);


1. {(true, true, true)}


1. select (False, false, FALSE);


1. {(false, false, false)}

A boolean value may arise as a result of a logical or comparison operations as well as in and not in:


1. select true and 2 < 3;


1. {true}


1. select '!' IN {'hello', 'world'};


1. {false}

It is also possible to cast between bool, str, and json:


1. select <json>true;


1. {'true'}


1. select <bool>'True';


1. {true}

Filter clauses must always evaluate to a boolean:


1. select User
2. filter .name ilike 'alice';

operator

bool or bool

Boolean - 图2

bool or bool -> bool

Logical disjunction.


1. select false or true;


1. {true}

operator

bool and bool

Boolean - 图3

bool and bool -> bool

Logical conjunction.


1. select false and true;


1. {false}

operator

not bool

Boolean - 图4

not bool -> bool

Logical negation.


1. select not false;


1. {true}

The and and or operators are commutative.

The truth tables are as follows:

a b a and b a or b not a
true true true true false
true false false true false
false true false true true
false false false false true