Fixed #3789 Erroneous LIMIT clause in prettyprinted SQL. 

Moved the default sql limit append such that it will only get append, if the limit is not added to the sql query explicitly.