WL-3603 Generate good SQL with no roles.

When there are no roles associated with a permission check we should still run the SQL correctly. The statement was failing because a bracket wasn’t closed when the roles were empty.
Merge pull request #51 from ox-it/WL-3603

WL-3603 Generate good SQL with no roles.
WL-2304 Don’t allow modification from the cache.

We were returning the object directly from the cache which meant that callers could modify the object and then this would be returned to future callers.