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

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