Database: implemented correct support for empty array NOT operator [Refs #667]

Removed old behavior, which could produce malformed SQL query.
Condition must have parentheses around all expressions with empty array.