(bug 33304) Fix ApiQueryAllPages duplicate rows in protection query

When querying for protection expiry without also querying protection
type(s), DISTINCT is not added to the query. Fix that.

Change-Id: I47d3ac1e0cfa6fa1fb0dc0089f5a01698b334cd5
(bug 37352) Boolean issue when using sqlite.

using a type cast instead, otherwise an empty string gets converted to
true when set with bool type.

Change-Id: I4161de32151a649161ab4084e80cafe4a462c7d5
Merge "(bug 37352) Boolean issue when using sqlite."