[Database] Rework handling environment flags
Summary: This will keep the code of the following changes simpler to read. It introduces no functional change.
Reviewers: ngraham, Baloo
Reviewed By: ngraham, Baloo
Subscribers: kde-frameworks-devel, ngraham, Baloo
Tags: Frameworks, Baloo
Differential Revision: https://phabricator.kde.org/D24539