Fix the database metadata queries

 to match the update I_S table changes for the sql-layer.

This will need my latest outstanding merge request to the sql-layer before this can go in.