(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
Merge pull request #215 from SemanticMediaWiki/sparql

(Bug 62150) SMWSparqlDatabaseError Malformed query order by: Unresolved ...