Fixed a logic issue in databaseprovider, needed it when not KEY_ID