(Bug 62150) SMWSparqlDatabaseError Malformed query order by: Unresolved prefixed name

Provided by Giacomo Carnevale (see [0]).

----
Added an integrity test.

[0] https://bugzilla.wikimedia.org/show_bug.cgi?id=62150