Fix minor db query issues for device deployments.
Fix minor db query issues for device deployments.

Signed-off-by: Maciej Mrowiec <0c5b7bd73e5de492f16f5039ef275802502d5ce2@gmail.com>

pasinskim/deployments,pasinskim/deployments,pasinskim/deployments,pasinskim/deployments