This is a temporary solution for OGR because we expect to use the native GDAL implementation in GDAL 3.2. For now a new method QgsSqliteUtils::uniqueFields used by spatialite and OGR/GPKG is used to detect UNIQUE constraints on single fields.