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.
Merge pull request #1105 from hrach/db-not

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